diff --git a/.github/in-cluster-test-scripts/eks.sh b/.github/in-cluster-test-scripts/eks.sh index 7aa22918a1..0ec2be53a2 100644 --- a/.github/in-cluster-test-scripts/eks.sh +++ b/.github/in-cluster-test-scripts/eks.sh @@ -10,7 +10,7 @@ cilium install \ --wait=false \ --helm-set loadBalancer.l7.backend=envoy \ --helm-set tls.secretsBackend=k8s \ - --config monitor-aggregation=none + --helm-set bpf.monitorAggregation=none # Enable Relay cilium hubble enable diff --git a/.github/workflows/eks.yaml b/.github/workflows/eks.yaml index 250ce4cee2..785734fc5e 100644 --- a/.github/workflows/eks.yaml +++ b/.github/workflows/eks.yaml @@ -26,7 +26,6 @@ concurrency: cancel-in-progress: true env: - clusterName: ${{ github.repository_owner }}-${{ github.event.repository.name }}-${{ github.run_id }} region: us-east-2 cilium_version: v1.13.2 kubectl_version: v1.23.6 @@ -36,7 +35,14 @@ jobs: if: ${{ github.repository == 'cilium/cilium-cli' }} runs-on: ubuntu-22.04 timeout-minutes: 60 + strategy: + matrix: + mode: ["classic", "helm"] steps: + - name: Set cluster name + run: | + echo "clusterName=${{ github.repository_owner }}-${{ github.event.repository.name }}-${{ github.run_id }}-${{ matrix.mode }}" >> $GITHUB_ENV + - name: Checkout uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 @@ -133,7 +139,8 @@ jobs: --generate-name \ --set tag=${{ steps.vars.outputs.sha }} \ --set cilium_version=${{ env.cilium_version }} \ - --set cluster_name=${{ env.clusterName }} + --set cluster_name=${{ env.clusterName }} \ + --set cilium_cli_mode=${{ matrix.mode }} - name: Wait for job env: diff --git a/install/install.go b/install/install.go index 752f507804..1f6cdfd474 100644 --- a/install/install.go +++ b/install/install.go @@ -626,6 +626,18 @@ func (k *K8sInstaller) listVersions() error { return err } +func getChainingMode(values map[string]interface{}) string { + cni, ok := values["cni"].(map[string]interface{}) + if !ok { + return "" + } + chainingMode, ok := cni["chainingMode"].(string) + if !ok { + return "" + } + return chainingMode +} + func (k *K8sInstaller) preinstall(ctx context.Context) error { if err := k.autodetectAndValidate(ctx); err != nil { return err @@ -658,7 +670,26 @@ func (k *K8sInstaller) preinstall(ctx context.Context) error { return err } } + case k8s.KindEKS: + helmValues, err := k.params.HelmOpts.MergeValues(getter.All(cli.New())) + if err != nil { + return err + } + chainingMode := getChainingMode(helmValues) + + // Do not stop AWS DS if we are running in chaining mode + if chainingMode != "aws-cni" { + if _, err := k.client.GetDaemonSet(ctx, AwsNodeDaemonSetNamespace, AwsNodeDaemonSetName, metav1.GetOptions{}); err == nil { + k.Log("🔥 Patching the %q DaemonSet to evict its pods...", AwsNodeDaemonSetName) + patch := []byte(fmt.Sprintf(`{"spec":{"template":{"spec":{"nodeSelector":{"%s":"%s"}}}}}`, AwsNodeDaemonSetNodeSelectorKey, AwsNodeDaemonSetNodeSelectorValue)) + if _, err := k.client.PatchDaemonSet(ctx, AwsNodeDaemonSetNamespace, AwsNodeDaemonSetName, types.StrategicMergePatchType, patch, metav1.PatchOptions{}); err != nil { + k.Log("❌ Unable to patch the %q DaemonSet", AwsNodeDaemonSetName) + return err + } + } + } } + return nil } @@ -699,23 +730,6 @@ func (k *K8sInstaller) Install(ctx context.Context) error { } switch k.flavor.Kind { - case k8s.KindEKS: - cm, err := k.generateConfigMap() - if err != nil { - return err - } - // Do not stop AWS DS if we are running in chaining mode - if cm.Data["cni-chaining-mode"] != "aws-cni" { - if _, err := k.client.GetDaemonSet(ctx, AwsNodeDaemonSetNamespace, AwsNodeDaemonSetName, metav1.GetOptions{}); err == nil { - k.Log("🔥 Patching the %q DaemonSet to evict its pods...", AwsNodeDaemonSetName) - patch := []byte(fmt.Sprintf(`{"spec":{"template":{"spec":{"nodeSelector":{"%s":"%s"}}}}}`, AwsNodeDaemonSetNodeSelectorKey, AwsNodeDaemonSetNodeSelectorValue)) - if _, err := k.client.PatchDaemonSet(ctx, AwsNodeDaemonSetNamespace, AwsNodeDaemonSetName, types.StrategicMergePatchType, patch, metav1.PatchOptions{}); err != nil { - k.Log("❌ Unable to patch the %q DaemonSet", AwsNodeDaemonSetName) - return err - } - } - } - case k8s.KindAKS: // We only made the secret-based azure installation available in >= 1.12.0 // Introduced in https://github.com/cilium/cilium/pull/18010 diff --git a/install/install_test.go b/install/install_test.go new file mode 100644 index 0000000000..baa52ccd87 --- /dev/null +++ b/install/install_test.go @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright Authors of Cilium + +package install + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "helm.sh/helm/v3/pkg/cli" + "helm.sh/helm/v3/pkg/cli/values" + "helm.sh/helm/v3/pkg/getter" +) + +func Test_getChainingMode(t *testing.T) { + assert.Equal(t, "", getChainingMode(nil)) + + opts := values.Options{} + vals, err := opts.MergeValues(getter.All(cli.New())) + assert.NoError(t, err) + assert.Equal(t, "", getChainingMode(vals)) + + opts = values.Options{JSONValues: []string{"cni={}"}} + vals, err = opts.MergeValues(getter.All(cli.New())) + assert.NoError(t, err) + assert.Equal(t, "", getChainingMode(vals)) + + opts = values.Options{Values: []string{"cni.chainingMode=aws-cni"}} + vals, err = opts.MergeValues(getter.All(cli.New())) + assert.NoError(t, err) + assert.Equal(t, "aws-cni", getChainingMode(vals)) +}