Skip to content

Commit

Permalink
enable leader election of klusterlet-agent on single node managed clu…
Browse files Browse the repository at this point in the history
…sters (#695)

Signed-off-by: Qing Hao <qhao@redhat.com>
  • Loading branch information
haoqing0110 authored Nov 15, 2024
1 parent 19cec98 commit 8544ff1
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ spec:
- "--spoke-external-server-urls={{ .ExternalServerURL }}"
{{end}}
{{if eq .Replica 1}}
- "--disable-leader-election"
- "--status-sync-interval=60s"
{{end}}
{{if gt .ClientCertExpirationSeconds 0}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ spec:
- "--spoke-kubeconfig=/spoke/config/kubeconfig"
- "--terminate-on-files=/spoke/config/kubeconfig"
{{end}}
{{if eq .Replica 1}}
- "--disable-leader-election"
{{end}}
{{if gt .ClientCertExpirationSeconds 0}}
- "--client-cert-expiration-seconds={{ .ClientCertExpirationSeconds }}"
{{end}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ spec:
{{end}}
- "--terminate-on-files=/spoke/hub-kubeconfig/kubeconfig"
{{if eq .Replica 1}}
- "--disable-leader-election"
- "--status-sync-interval=60s"
{{end}}
{{if gt .WorkKubeAPIQPS 0.0}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,8 @@ func assertKlusterletDeployment(t *testing.T, actions []clienttesting.Action, ve
expectedArgs = append(expectedArgs, fmt.Sprintf("--spoke-external-server-urls=%s", serverURL))
}

expectedArgs = append(expectedArgs, "--agent-id=", "--workload-source-driver=kube", "--workload-source-config=/spoke/hub-kubeconfig/kubeconfig")

if *deployment.Spec.Replicas == 1 {
expectedArgs = append(expectedArgs, "--disable-leader-election")
}

expectedArgs = append(expectedArgs, "--status-sync-interval=60s", "--kube-api-qps=20", "--kube-api-burst=60",
expectedArgs = append(expectedArgs, "--agent-id=", "--workload-source-driver=kube", "--workload-source-config=/spoke/hub-kubeconfig/kubeconfig",
"--status-sync-interval=60s", "--kube-api-qps=20", "--kube-api-burst=60",
"--registration-auth=awsirsa", "--hub-cluster-arn=arneks:us-west-2:123456789012:cluster/hub-cluster1")

if !equality.Semantic.DeepEqual(args, expectedArgs) {
Expand Down Expand Up @@ -438,10 +433,6 @@ func assertRegistrationDeployment(t *testing.T, actions []clienttesting.Action,
expectedArgs = append(expectedArgs, fmt.Sprintf("--spoke-external-server-urls=%s", serverURL))
}

if *deployment.Spec.Replicas == 1 {
expectedArgs = append(expectedArgs, "--disable-leader-election")
}

expectedArgs = append(expectedArgs, "--kube-api-qps=10", "--kube-api-burst=60")
if awsAuth {
expectedArgs = append(expectedArgs, "--registration-auth=awsirsa", "--hub-cluster-arn=arneks:us-west-2:123456789012:cluster/hub-cluster1")
Expand Down Expand Up @@ -485,7 +476,7 @@ func assertWorkDeployment(t *testing.T, actions []clienttesting.Action, verb, cl
expectArgs = append(expectArgs, "--terminate-on-files=/spoke/hub-kubeconfig/kubeconfig")

if *deployment.Spec.Replicas == 1 {
expectArgs = append(expectArgs, "--disable-leader-election", "--status-sync-interval=60s")
expectArgs = append(expectArgs, "--status-sync-interval=60s")
}

expectArgs = append(expectArgs, "--kube-api-qps=20", "--kube-api-burst=50")
Expand Down
4 changes: 2 additions & 2 deletions test/integration/operator/klusterlet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ var _ = ginkgo.Describe("Klusterlet", func() {
gomega.Expect(len(actual.Spec.Template.Spec.Containers)).Should(gomega.Equal(1))
// klusterlet has no condition, replica is 0
gomega.Expect(actual.Status.Replicas).Should(gomega.Equal(int32(0)))
gomega.Expect(len(actual.Spec.Template.Spec.Containers[0].Args)).Should(gomega.Equal(9))
gomega.Expect(len(actual.Spec.Template.Spec.Containers[0].Args)).Should(gomega.Equal(8))
return actual.Spec.Template.Spec.Containers[0].Args[2] != "--spoke-cluster-name=cluster2"
}, eventuallyTimeout, eventuallyInterval).Should(gomega.BeTrue())

Expand All @@ -602,7 +602,7 @@ var _ = ginkgo.Describe("Klusterlet", func() {
return false
}
gomega.Expect(len(actual.Spec.Template.Spec.Containers)).Should(gomega.Equal(1))
gomega.Expect(len(actual.Spec.Template.Spec.Containers[0].Args)).Should(gomega.Equal(6))
gomega.Expect(len(actual.Spec.Template.Spec.Containers[0].Args)).Should(gomega.Equal(5))
return actual.Spec.Template.Spec.Containers[0].Args[2] == "--spoke-cluster-name=cluster2"
}, eventuallyTimeout, eventuallyInterval).Should(gomega.BeTrue())

Expand Down

0 comments on commit 8544ff1

Please sign in to comment.