Skip to content

Commit

Permalink
deploy virtualcluster control plane on master nodes
Browse files Browse the repository at this point in the history
Signed-off-by: zhouhaoA1 <[email protected]>
  • Loading branch information
zhouhaoA1 committed Apr 25, 2024
1 parent 55dd351 commit 9422f0f
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ spec:
spec:
automountServiceAccountToken: false
hostNetwork: true
tolerations:
- key: "node-role.kubernetes.io/control-plane"
operator: "Exists"
effect: "NoSchedule"
containers:
- name: kube-apiserver
image: {{ .ImageRepository }}/kube-apiserver:{{ .Version }}
Expand Down Expand Up @@ -81,6 +85,12 @@ spec:
successThreshold: 1
timeoutSeconds: 15
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/control-plane
operator: Exists
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
Expand Down
21 changes: 19 additions & 2 deletions pkg/kubenest/manifest/controlplane/etcd/mainfests_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,27 @@ spec:
metadata:
labels:
virtualCluster-app: etcd
tolerations:
- operator: Exists
spec:
automountServiceAccountToken: false
tolerations:
- key: "node-role.kubernetes.io/control-plane"
operator: "Exists"
effect: "NoSchedule"
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/control-plane
operator: Exists
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: virtualCluster-app
operator: In
values: ["etcd"]
topologyKey: kubernetes.io/hostname
containers:
- name: etcd
image: {{ .ImageRepository }}/etcd:{{ .Version }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@ spec:
spec:
automountServiceAccountToken: false
priorityClassName: system-node-critical
tolerations:
- key: "node-role.kubernetes.io/control-plane"
operator: "Exists"
effect: "NoSchedule"
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/control-plane
operator: Exists
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,25 @@ spec:
virtualCluster-app: scheduler
spec:
automountServiceAccountToken: false
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
tolerations:
- key: "node-role.kubernetes.io/control-plane"
operator: "Exists"
effect: "NoSchedule"
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/control-plane
operator: Exists
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: virtualCluster-app
operator: In
values: ["scheduler"]
topologyKey: kubernetes.io/hostname
containers:
- name: scheduler
image: {{ .ImageRepository }}/scheduler:{{ .Version }}
Expand Down
10 changes: 5 additions & 5 deletions pkg/kubenest/tasks/manifests_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ func applyComponentsManifests(r workflow.RunData) error {
return err
}

templatedMapping := make(map[string]interface{}, 2)
templatedMapping["KUBE_PROXY_KUBECONFIG"] = string(secret.Data[constants.KubeConfig])
imageRepository, _ := util.GetImageMessage()
templatedMapping["ImageRepository"] = imageRepository

for _, component := range components {
klog.V(2).Infof("Deploy component %s", component.Name)

templatedMapping := make(map[string]interface{}, 2)
if component.Name == constants.VirtualClusterKubeProxyComponent {
templatedMapping["KUBE_PROXY_KUBECONFIG"] = string(secret.Data[constants.KubeConfig])
}
err = applyTemplatedManifests(dynamicClient, component.Path, templatedMapping)
if err != nil {
return err
Expand Down

0 comments on commit 9422f0f

Please sign in to comment.