diff --git a/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/metacluster/tasks/gitops.yml b/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/metacluster/tasks/gitops.yml index 5948034..8157a00 100644 --- a/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/metacluster/tasks/gitops.yml +++ b/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/metacluster/tasks/gitops.yml @@ -39,7 +39,7 @@ mode: 0600 vars: _template: - name: argocd-gitrepo-mc-gitopsconfig + name: gitrepo-mc-gitopsconfig namespace: argo-cd url: https://git.{{ vapp['metacluster.fqdn'] }}/mc/GitOps.Config.git notify: diff --git a/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/clusterapi.yml b/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/clusterapi.yml index 360e138..70e6e0b 100644 --- a/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/clusterapi.yml +++ b/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/clusterapi.yml @@ -52,13 +52,12 @@ version: "{{ components.clusterapi.workload.version.k8s }}" vip: "{{ vapp['workloadcluster.vip'] }}" -- name: Generate kustomization template +- name: Generate cluster-template kustomization manifest ansible.builtin.template: src: kustomization.cluster-template.j2 dest: /opt/metacluster/cluster-api/infrastructure-vsphere/{{ components.clusterapi.management.version.infrastructure_vsphere }}/kustomization.yaml vars: _template: - additionaldisk: "{{ vapp['workloadcluster.additionaldisk'] }}" network: fqdn: "{{ vapp['metacluster.fqdn'] }}" dnsserver: "{{ vapp['guestinfo.dnsserver'] }}" @@ -105,7 +104,8 @@ clustersize: >- {{ { 'controlplane': vapp['deployment.type'] | regex_findall('^cp(\d)+') | first, - 'workers': vapp['deployment.type'] | regex_findall('w(\d)+$') | first + 'worker': vapp['deployment.type'] | regex_findall('w(\d)+$') | first, + 'workerstorage': vapp['deployment.type'] | regex_findall('ws(\d)+') | first } }} - name: Generate workload cluster manifest @@ -114,7 +114,7 @@ clusterctl generate cluster \ {{ vapp['workloadcluster.name'] | lower }} \ --control-plane-machine-count {{ clustersize.controlplane }} \ - --worker-machine-count {{ clustersize.workers }} \ + --worker-machine-count {{ clustersize.worker }} \ --from ./custom-cluster-template.yaml \ --config ./clusterctl.yaml \ --kubeconfig {{ kubeconfig.path }} @@ -138,6 +138,23 @@ -f {{ capi_clustermanifest.path }}/new-cluster.yaml \ -o {{ capi_clustermanifest.path }}/manifests +- name: Generate nodepool kustomization manifest + ansible.builtin.template: + src: kustomization.nodepool.j2 + dest: "{{ capi_clustermanifest.path }}/kustomization.yaml" + vars: + _template: + cluster: + name: "{{ vapp['workloadcluster.name'] }}" + nodepool: + size: "{{ clustersize.workerstorage }}" + additionaldisk: "{{ vapp['workloadcluster.additionaldisk'] }}" + +- name: Store nodepool manifest + ansible.builtin.copy: + dest: "{{ capi_clustermanifest.path }}/manifests/nodepool-worker-storage.yaml" + content: "{{ lookup('kubernetes.core.kustomize', dir=capi_clustermanifest.path) }}" + - name: Create in-cluster IpPool ansible.builtin.template: src: ippool.j2 @@ -181,7 +198,7 @@ mode: 0600 vars: _template: - name: argocd-gitrepo-mc-gitopsclusterapi + name: gitrepo-mc-gitopsclusterapi namespace: argo-cd url: https://git.{{ vapp['metacluster.fqdn'] }}/mc/GitOps.ClusterAPI.git notify: diff --git a/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/gitops.yml b/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/gitops.yml index bc6f7e5..31e5585 100644 --- a/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/gitops.yml +++ b/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/gitops.yml @@ -75,7 +75,7 @@ mode: 0600 vars: _template: - name: argocd-gitrepo-wl-gitopsconfig + name: gitrepo-wl-gitopsconfig namespace: argo-cd url: https://git.{{ vapp['metacluster.fqdn'] }}/wl/GitOps.Config.git notify: diff --git a/ansible/roles/firstboot/files/ansible_payload/bootstrap/templates/kustomization.cluster-template.j2 b/ansible/roles/firstboot/files/ansible_payload/bootstrap/templates/kustomization.cluster-template.j2 index c9c1c18..afb747d 100644 --- a/ansible/roles/firstboot/files/ansible_payload/bootstrap/templates/kustomization.cluster-template.j2 +++ b/ansible/roles/firstboot/files/ansible_payload/bootstrap/templates/kustomization.cluster-template.j2 @@ -25,18 +25,6 @@ patchesStrategicMerge: spec: clusterConfiguration: imageRepository: registry.{{ _template.network.fqdn }}/kubeadm - diskSetup: - filesystems: - - device: /dev/sdb1 - filesystem: ext4 - label: blockstorage - partitions: - - device: /dev/sdb - layout: true - tableType: gpt - mounts: - - - LABEL=blockstorage - - /mnt/blockstorage - |- apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 kind: KubeadmConfigTemplate @@ -98,8 +86,6 @@ patchesStrategicMerge: spec: template: spec: - additionalDisksGiB: - - {{ _template.additionaldisk }} network: devices: - dhcp4: false @@ -176,28 +162,6 @@ patchesJson6902: value: {{ cmd }} {% endfor %} - - target: - group: cluster.x-k8s.io - version: v1beta1 - kind: MachineDeployment - name: \${CLUSTER_NAME}-md-0 - patch: |- - - op: replace - path: /metadata/name - value: ${CLUSTER_NAME}-worker - - op: replace - path: /spec/template/spec/bootstrap/configRef/name - value: ${CLUSTER_NAME}-worker - - target: - group: bootstrap.cluster.x-k8s.io - version: v1beta1 - kind: KubeadmConfigTemplate - name: \${CLUSTER_NAME}-md-0 - patch: |- - - op: replace - path: /metadata/name - value: ${CLUSTER_NAME}-worker - - target: group: infrastructure.cluster.x-k8s.io version: v1beta1 @@ -228,3 +192,25 @@ patchesJson6902: - op: replace path: /spec/controlPlaneRef/name value: ${CLUSTER_NAME}-master + + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: MachineDeployment + name: \${CLUSTER_NAME}-md-0 + patch: |- + - op: replace + path: /metadata/name + value: ${CLUSTER_NAME}-worker + - op: replace + path: /spec/template/spec/bootstrap/configRef/name + value: ${CLUSTER_NAME}-worker + - target: + group: bootstrap.cluster.x-k8s.io + version: v1beta1 + kind: KubeadmConfigTemplate + name: \${CLUSTER_NAME}-md-0 + patch: |- + - op: replace + path: /metadata/name + value: ${CLUSTER_NAME}-worker diff --git a/ansible/roles/firstboot/files/ansible_payload/bootstrap/templates/kustomization.nodepool.j2 b/ansible/roles/firstboot/files/ansible_payload/bootstrap/templates/kustomization.nodepool.j2 new file mode 100644 index 0000000..9cd2a33 --- /dev/null +++ b/ansible/roles/firstboot/files/ansible_payload/bootstrap/templates/kustomization.nodepool.j2 @@ -0,0 +1,74 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- manifests/kubeadmconfigtemplate-{{ _template.cluster.name }}-worker.yaml +- manifests/machinedeployment-{{ _template.cluster.name }}-worker.yaml +- manifests/vspheremachinetemplate-{{ _template.cluster.name }}-worker.yaml + +patchesStrategicMerge: + - |- + apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 + kind: KubeadmConfigTemplate + metadata: + name: {{ _template.cluster.name }}-worker + namespace: default + spec: + template: + spec: + diskSetup: + filesystems: + - device: /dev/sdb1 + filesystem: ext4 + label: blockstorage + partitions: + - device: /dev/sdb + layout: true + tableType: gpt + mounts: + - - LABEL=blockstorage + - /mnt/blockstorage + +patchesJson6902: + - target: + group: bootstrap.cluster.x-k8s.io + version: v1beta1 + kind: KubeadmConfigTemplate + name: {{ _template.cluster.name }}-worker + patch: |- + - op: replace + path: /metadata/name + value: {{ _template.cluster.name }}-worker-storage + + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: MachineDeployment + name: {{ _template.cluster.name }}-worker + patch: |- + - op: replace + path: /metadata/name + value: {{ _template.cluster.name }}-worker-storage + - op: replace + path: /spec/template/spec/bootstrap/configRef/name + value: {{ _template.cluster.name }}-worker-storage + - op: replace + path: /spec/template/spec/infrastructureRef/name + value: {{ _template.cluster.name }}-worker-storage + - op: replace + path: /spec/replicas + value: {{ _template.nodepool.size }} + + - target: + group: infrastructure.cluster.x-k8s.io + version: v1beta1 + kind: VSphereMachineTemplate + name: {{ _template.cluster.name }}-worker + patch: |- + - op: replace + path: /metadata/name + value: {{ _template.cluster.name }}-worker-storage + - op: add + path: /spec/template/spec + value: + additionalDisksGiB: + - {{ _template.nodepool.additionaldisk }} diff --git a/scripts/Update-OvfConfiguration.bootstrap.yml b/scripts/Update-OvfConfiguration.bootstrap.yml index 3204984..9514fe5 100644 --- a/scripts/Update-OvfConfiguration.bootstrap.yml +++ b/scripts/Update-OvfConfiguration.bootstrap.yml @@ -1,11 +1,11 @@ DeploymentConfigurations: -- Id: cp1w1 +- Id: cp1w1ws0 Label: 'Workload-cluster: 1 control-plane node/1 worker node' Description: 1 control-plane node/1 worker node -- Id: cp1w2 - Label: 'Workload-cluster: 1 control-plane node/2 worker nodes' +- Id: cp1w1ws1 + Label: 'Workload-cluster: 1 control-plane node/1 worker node/1 worker-storage node' Description: 1 control-plane node/2 worker nodes - Id: core @@ -28,8 +28,8 @@ PropertyCategories: - Key: deployment.type Type: string Value: - - cp1w1 - - cp1w2 + - cp1w1ws0 + - cp1w1ws1 - core UserConfigurable: false @@ -128,8 +128,8 @@ PropertyCategories: Description: '' DefaultValue: 'workload-{{ hostname.suffix }}' Configurations: - - cp1w1 - - cp1w2 + - cp1w1ws0 + - cp1w1ws1 UserConfigurable: true - Key: workloadcluster.vip @@ -138,8 +138,8 @@ PropertyCategories: Description: Workload-cluster control plane endpoint virtual IP address DefaultValue: '0.0.0.0' Configurations: - - cp1w1 - - cp1w2 + - cp1w1ws0 + - cp1w1ws1 UserConfigurable: true - Key: ippool.startip @@ -148,8 +148,8 @@ PropertyCategories: Description: All nodes for the workload-cluster will be provisioned within this IP pool DefaultValue: '0.0.0.0' Configurations: - - cp1w1 - - cp1w2 + - cp1w1ws0 + - cp1w1ws1 UserConfigurable: true - Key: ippool.endip @@ -158,8 +158,8 @@ PropertyCategories: Description: All nodes for the workload-cluster will be provisioned within this IP pool DefaultValue: '0.0.0.0' Configurations: - - cp1w1 - - cp1w2 + - cp1w1ws0 + - cp1w1ws1 UserConfigurable: true - Key: workloadcluster.nodesize @@ -171,18 +171,18 @@ PropertyCategories: - MEDIUM: 4 vCPU/8GB RAM DefaultValue: 'small' Configurations: - - cp1w1 - - cp1w2 + - cp1w1ws0 + - cp1w1ws1 UserConfigurable: true - Key: workloadcluster.additionaldisk Type: int(0..120) Label: Workload-cluster block storage disk size* - Description: 'All worker-nodes for the workload-cluster will be provisioned with an additional disk of the specified size' + Description: 'All worker-storage nodes for the workload-cluster will be provisioned with an additional disk of the specified size' DefaultValue: '20' Configurations: - - cp1w1 - - cp1w2 + - cp1w1ws0 + - cp1w1ws1 UserConfigurable: true - Name: 4) Common