Skip to content

Commit

Permalink
Support add worker node by creating MachineDeployment
Browse files Browse the repository at this point in the history
Signed-off-by: ekko <lihai.tu@daocloud.io>
  • Loading branch information
0ekk committed Feb 17, 2025
1 parent 6d56d7f commit 699dd77
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 9 deletions.
3 changes: 0 additions & 3 deletions docs/tilt.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ kustomize_substitutions:

ECS_IMAGE_ID: "a9f5cc27-0d50-4864-a45e-d8eead734a3f"

KUBE_IMAGE_REPO: "registry.cn-hangzhou.aliyuncs.com/google_containers"
KUBE_DNS_IMAGE_REPO: "registry.cn-hangzhou.aliyuncs.com/google_containers"
ETCD_IMAGE_REPO: "registry.cn-hangzhou.aliyuncs.com/google_containers"
```

**Note:** Please ensure that the values for `CLOUD_SDK_AK` and `CLOUD_SDK_SK` are base64 encoded.
Expand Down
1 change: 1 addition & 0 deletions pkg/services/ecs/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func (s *Service) GetCoreSecurityGroups(scope *scope.MachineScope) ([]string, er
switch scope.Role() {
case "control-plane":
sgRoles = append(sgRoles, infrav1.SecurityGroupControlPlane)
case "node":
default:
return nil, errors.Errorf("Unknown node role %q", scope.Role())
}
Expand Down
53 changes: 47 additions & 6 deletions templates/cluster-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ spec:
controllerManager:
extraArgs:
cloud-provider: external
etcd:
local:
imageRepository: "${ETCD_IMAGE_REPO}"
dns:
imageRepository: "${KUBE_DNS_IMAGE_REPO}"
imageRepository: "${KUBE_IMAGE_REPO}"
initConfiguration:
nodeRegistration:
kubeletExtraArgs:
Expand Down Expand Up @@ -72,4 +66,51 @@ spec:
spec:
imageRef: "${ECS_IMAGE_ID}"
flavorRef: "${HC_CONTROL_PLANE_MACHINE_TYPE}"
publicIP: true
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: "${CLUSTER_NAME}-md-0"
spec:
clusterName: "${CLUSTER_NAME}"
replicas: ${WORKER_MACHINE_COUNT}
selector:
matchLabels: null
template:
spec:
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: "${CLUSTER_NAME}-md-0"
clusterName: ${CLUSTER_NAME}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: HuaweiCloudMachineTemplate
name: "${CLUSTER_NAME}-md-0"
version: ${KUBERNETES_VERSION}
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: "${CLUSTER_NAME}-md-0"
spec:
template:
spec:
joinConfiguration:
nodeRegistration:
kubeletExtraArgs:
cloud-provider: external
name: '{{ ds.meta_data.local_hostname }}'
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: HuaweiCloudMachineTemplate
metadata:
name: "${CLUSTER_NAME}-md-0"
spec:
template:
spec:
imageRef: "${ECS_IMAGE_ID}"
flavorRef: "${HC_NODE_MACHINE_TYPE}"
publicIP: true

0 comments on commit 699dd77

Please sign in to comment.