Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helm mode: Add EKS test coverage #1638

Merged
merged 2 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/in-cluster-test-scripts/eks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/eks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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:
Expand Down
48 changes: 31 additions & 17 deletions install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions install/install_test.go
Original file line number Diff line number Diff line change
@@ -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))
}