Skip to content

Commit

Permalink
Add templates to generate vpc-clusterclass template
Browse files Browse the repository at this point in the history
  • Loading branch information
kishen-v committed Nov 17, 2023
1 parent bfbfb08 commit 0c07826
Show file tree
Hide file tree
Showing 4 changed files with 212 additions and 47 deletions.
92 changes: 45 additions & 47 deletions templates/cluster-template-vpc-clusterclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ spec:
version: ${KUBERNETES_VERSION}
workers:
machineDeployments:
- class: default-worker
name: md-0
replicas: 2
- class: default-worker
name: md-0
replicas: ${WORKER_MACHINE_COUNT}
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: ClusterClass
Expand All @@ -51,18 +51,18 @@ spec:
namespace: ${NAMESPACE}
workers:
machineDeployments:
- class: default-worker
template:
bootstrap:
ref:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: ${IBMVPC_CLUSTER_CLASS_NAME}-md-0
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: IBMVPCMachineTemplate
name: ${IBMVPC_CLUSTER_CLASS_NAME}-worker-machinetemplate
- class: default-worker
template:
bootstrap:
ref:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: ${IBMVPC_CLUSTER_CLASS_NAME}-md-0
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: IBMVPCMachineTemplate
name: ${IBMVPC_CLUSTER_CLASS_NAME}-worker-machinetemplate
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: IBMVPCClusterTemplate
Expand All @@ -88,41 +88,39 @@ spec:
spec:
kubeadmConfigSpec:
clusterConfiguration:
kubernetesVersion: ${KUBERNETES_VERSION}
apiServer:
certSANs: [localhost, 127.0.0.1]
certSANs:
- localhost
- 127.0.0.1
extraArgs:
cloud-provider: external
controllerManager:
extraArgs:
enable-hostpath-provisioner: 'true'
cloud-provider: external
apiServer:
certSANs: [localhost, 127.0.0.1]
extraArgs:
cloud-provider: external
enable-hostpath-provisioner: "true"
dns: {}
etcd: {}
kubernetesVersion: ${KUBERNETES_VERSION}
networking: {}
scheduler: {}
initConfiguration:
nodeRegistration:
criSocket: /var/run/containerd/containerd.sock
kubeletExtraArgs:
kubeletExtraArgs:
cloud-provider: external
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'
eviction-hard: nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%
joinConfiguration:
discovery: {}
nodeRegistration:
criSocket: /var/run/containerd/containerd.sock
kubeletExtraArgs:
kubeletExtraArgs:
cloud-provider: external
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'
eviction-hard: nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: "${IBMVPC_CLUSTER_CLASS_NAME}-md-0"
name: ${IBMVPC_CLUSTER_CLASS_NAME}-md-0
spec:
template:
spec:
Expand Down Expand Up @@ -151,18 +149,18 @@ spec:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: IBMVPCMachineTemplate
metadata:
name: "${IBMVPC_CLUSTER_CLASS_NAME}-worker-machinetemplate"
name: ${IBMVPC_CLUSTER_CLASS_NAME}-worker-machinetemplate
spec:
template:
spec:
image:
name: "${IBMVPC_IMAGE_NAME}"
zone: "${IBMVPC_ZONE}"
profile: "${IBMVPC_PROFILE}"
sshKeys:
- name: "${IBMVPC_SSHKEY_NAME}"
bootVolume:
sizeGiB: ${IBMVPC_WORKER_BOOT_VOLUME_SIZEGIB:=20}
image:
name: ${IBMVPC_IMAGE_NAME}
profile: ${IBMVPC_PROFILE}
sshKeys:
- name: ${IBMVPC_SSHKEY_NAME}
zone: ${IBMVPC_ZONE}
---
apiVersion: addons.cluster.x-k8s.io/v1beta1
kind: ClusterResourceSet
Expand All @@ -173,18 +171,15 @@ spec:
matchLabels:
ccm: external
resources:
- kind: Secret
name: ibm-credential
- kind: ConfigMap
name: ibm-cfg
- kind: ConfigMap
name: cloud-controller-manager-addon
- kind: Secret
name: ibm-credential
- kind: ConfigMap
name: ibm-cfg
- kind: ConfigMap
name: cloud-controller-manager-addon
strategy: ApplyOnce
---
apiVersion: v1
kind: ConfigMap
metadata:
name: ibm-cfg
data:
ibm-cloud-conf.yaml: |-
apiVersion: v1
Expand All @@ -208,12 +203,14 @@ data:
g2VpcSubnetNames = "${CLUSTER_NAME}-subnet"
g2VpcName = ${IBMVPC_NAME:=""}
region = ${IBMVPC_REGION:=""}
kind: ConfigMap
metadata:
name: ibm-cfg
---
apiVersion: v1
kind: Secret
metadata:
name: ibm-credential
type: addons.cluster.x-k8s.io/resource-set
stringData:
ibm-credential.yaml: |-
apiVersion: v1
Expand All @@ -223,11 +220,9 @@ stringData:
namespace: kube-system
data:
ibmcloud_api_key: ${BASE64_API_KEY}
type: addons.cluster.x-k8s.io/resource-set
---
apiVersion: v1
kind: ConfigMap
metadata:
name: cloud-controller-manager-addon
data:
ibm-ccm-external.yaml: |-
apiVersion: v1
Expand Down Expand Up @@ -420,3 +415,6 @@ data:
- name: ibm-secret
secret:
secretName: ibm-cloud-credential
kind: ConfigMap
metadata:
name: cloud-controller-manager-addon
116 changes: 116 additions & 0 deletions templates/cluster-template-vpc-clusterclass/cluster-with-kcp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
labels:
ccm: external
cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME}
name: ${CLUSTER_NAME}
namespace: ${NAMESPACE}
spec:
clusterNetwork:
pods:
cidrBlocks:
- ${POD_CIDR:="192.168.0.0/16"}
serviceDomain: ${SERVICE_DOMAIN:="cluster.local"}
services:
cidrBlocks:
- ${SERVICE_CIDR:="10.128.0.0/12"}
topology:
class: ${IBMVPC_CLUSTER_CLASS_NAME}
controlPlane:
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
version: ${KUBERNETES_VERSION}
workers:
machineDeployments:
- class: default-worker
name: md-0
replicas: ${WORKER_MACHINE_COUNT}
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: ClusterClass
metadata:
name: ${IBMVPC_CLUSTER_CLASS_NAME:="vpc-cc"}
spec:
controlPlane:
machineInfrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: IBMVPCMachineTemplate
name: ${IBMVPC_CLUSTER_CLASS_NAME}-control-plane-machinetemplate
namespace: ${NAMESPACE}
ref:
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlaneTemplate
name: ${IBMVPC_CLUSTER_CLASS_NAME}-control-plane
namespace: ${NAMESPACE}
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: IBMVPCClusterTemplate
name: ${IBMVPC_CLUSTER_CLASS_NAME}-cluster-template
namespace: ${NAMESPACE}
workers:
machineDeployments:
- class: default-worker
template:
bootstrap:
ref:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: ${IBMVPC_CLUSTER_CLASS_NAME}-md-0
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: IBMVPCMachineTemplate
name: ${IBMVPC_CLUSTER_CLASS_NAME}-worker-machinetemplate
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: IBMVPCClusterTemplate
metadata:
name: ${IBMVPC_CLUSTER_CLASS_NAME}-cluster-template
spec:
template:
spec:
controlPlaneLoadBalancer:
name: ${CLUSTER_NAME}-load-balancer
region: ${IBMVPC_REGION}
resourceGroup: ${IBMVPC_RESOURCEGROUP}
vpc: ${IBMVPC_NAME}
zone: ${IBMVPC_ZONE}
---
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlaneTemplate
metadata:
name: ${IBMVPC_CLUSTER_CLASS_NAME}-control-plane
namespace: ${NAMESPACE}
spec:
template:
spec:
kubeadmConfigSpec:
clusterConfiguration:
kubernetesVersion: ${KUBERNETES_VERSION}
apiServer:
certSANs: [localhost, 127.0.0.1]
extraArgs:
cloud-provider: external
controllerManager:
extraArgs:
enable-hostpath-provisioner: 'true'
cloud-provider: external
dns: {}
etcd: {}
networking: {}
scheduler: {}
initConfiguration:
nodeRegistration:
criSocket: /var/run/containerd/containerd.sock
kubeletExtraArgs:
cloud-provider: external
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'
joinConfiguration:
discovery: {}
nodeRegistration:
criSocket: /var/run/containerd/containerd.sock
kubeletExtraArgs:
cloud-provider: external
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resources:
- cluster-with-kcp.yaml
- md.yaml
- ../addons/crs.yaml

sortOptions:
order: fifo
44 changes: 44 additions & 0 deletions templates/cluster-template-vpc-clusterclass/md.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: "${IBMVPC_CLUSTER_CLASS_NAME}-md-0"
spec:
template:
spec:
joinConfiguration:
nodeRegistration:
kubeletExtraArgs:
cloud-provider: external
eviction-hard: nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: IBMVPCMachineTemplate
metadata:
name: ${IBMVPC_CLUSTER_CLASS_NAME}-control-plane-machinetemplate
spec:
template:
spec:
bootVolume:
sizeGiB: ${IBMVPC_CONTROLPLANE_BOOT_VOLUME_SIZEGIB:=20}
image:
name: ${IBMVPC_IMAGE_NAME}
profile: ${IBMVPC_PROFILE}
sshKeys:
- name: ${IBMVPC_SSHKEY_NAME}
zone: ${IBMVPC_ZONE}
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: IBMVPCMachineTemplate
metadata:
name: "${IBMVPC_CLUSTER_CLASS_NAME}-worker-machinetemplate"
spec:
template:
spec:
image:
name: "${IBMVPC_IMAGE_NAME}"
zone: "${IBMVPC_ZONE}"
profile: "${IBMVPC_PROFILE}"
sshKeys:
- name: "${IBMVPC_SSHKEY_NAME}"
bootVolume:
sizeGiB: ${IBMVPC_WORKER_BOOT_VOLUME_SIZEGIB:=20}

0 comments on commit 0c07826

Please sign in to comment.