Skip to content

Commit

Permalink
Merge pull request #7 from dippynark/create-flavors
Browse files Browse the repository at this point in the history
Create and document flavors
  • Loading branch information
dippynark authored Mar 8, 2021
2 parents 16d22b7 + 9ccf457 commit 0af034e
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 37 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ CLUSTER_NAME="example"

# Use ClusterIP for clusters that do not support Services of type LoadBalancer
export KUBERNETES_CONTROL_PLANE_SERVICE_TYPE="LoadBalancer"
export KUBERNETES_CONTROL_PLANE_MACHINE_CPU_REQUESTS="1"
export KUBERNETES_CONTROL_PLANE_MACHINE_MEMORY_REQUESTS="1Gi"
export KUBERNETES_NODE_MACHINE_CPU_REQUESTS="1"
export KUBERNETES_NODE_MACHINE_MEMORY_REQUESTS="1Gi"
export KUBERNETES_CONTROLLER_MACHINE_CPU_REQUEST="1"
export KUBERNETES_CONTROLLER_MACHINE_MEMORY_REQUEST="2Gi"
export KUBERNETES_WORKER_MACHINE_CPU_REQUEST="1"
export KUBERNETES_WORKER_MACHINE_MEMORY_REQUEST="1Gi"
clusterctl config cluster $CLUSTER_NAME \
--kubernetes-version=v1.20.2 \
--control-plane-machine-count=1 \
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
- [KubernetesMachines](kubernetes-machines.md)
- [Remediation](remediation.md)
- [Persistence](persistence.md)
- [Flavors](flavors.md)
- [E2E Tests](e2e-tests.md)
42 changes: 42 additions & 0 deletions docs/flavors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Flavors

Cluster API Provider Kubernetes supports a number of
[flavors](https://cluster-api.sigs.k8s.io/clusterctl/commands/config-cluster.html#flavors) for
creating clusters. Flavors are YAML templates that can by hydrated using
[clusterctl](https://cluster-api.sigs.k8s.io/clusterctl/commands/commands.html).

## Default

| Variable | Required | Default |
| - | - | - |
| CLUSTER_NAME | Yes | |
| KUBERNETES_CONTROL_PLANE_SERVICE_TYPE | Yes | |
| CONTROL_PLANE_MACHINE_COUNT | No | 1 |
| WORKER_MACHINE_COUNT | No | 1 |
| KUBERNETES_CONTROLLER_MACHINE_CPU_REQUEST | No | 0 |
| KUBERNETES_CONTROLLER_MACHINE_MEMORY_REQUEST | No | 0 |
| KUBERNETES_WORKER_MACHINE_CPU_REQUEST | No | 0 |
| KUBERNETES_WORKER_MACHINE_MEMORY_REQUEST | No | 0 |
| SERVICE_CIDR | No | ["10.128.0.0/12"] |
| POD_CIDR | No | ["192.168.0.0/16"] |
| SERVICE_DOMAIN | No | cluster.local |

## Persistent Control Plane

> `clusterctl config create --flavor persistent-control-plane`
| Variable | Required | Default |
| - | - | - |
| CLUSTER_NAME | Yes | |
| KUBERNETES_CONTROL_PLANE_SERVICE_TYPE | Yes | |
| ETCD_STORAGE_CLASS_NAME | Yes | |
| ETCD_STORAGE_SIZE | Yes | |
| CONTROL_PLANE_MACHINE_COUNT | No | 1 |
| WORKER_MACHINE_COUNT | No | 1 |
| KUBERNETES_CONTROLLER_MACHINE_CPU_REQUEST | No | 0 |
| KUBERNETES_CONTROLLER_MACHINE_MEMORY_REQUEST | No | 0 |
| KUBERNETES_WORKER_MACHINE_CPU_REQUEST | No | 0 |
| KUBERNETES_WORKER_MACHINE_MEMORY_REQUEST | No | 0 |
| SERVICE_CIDR | No | ["10.128.0.0/12"] |
| POD_CIDR | No | ["192.168.0.0/16"] |
| SERVICE_DOMAIN | No | cluster.local |
6 changes: 0 additions & 6 deletions docs/persistence.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,3 @@ spec:
requests:
storage: 10Gi
```
The
[release/cluster-template-persistent-control-plane.yaml](../release/cluster-template-persistent-control-plane.yaml)
template configures persistent controller Machines using the default StorageClass. Note that it is
[recommended to back etcd's storage with an
SSD](https://etcd.io/docs/v3.3.12/op-guide/hardware/#disks).
1 change: 1 addition & 0 deletions e2e/config/capk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ providers:

variables:
KUBERNETES_VERSION: "v1.20.2"
KUBERNETES_CONTROL_PLANE_SERVICE_TYPE: "ClusterIP"
CNI: "./data/cni/calico/calico.yaml"
EXP_CLUSTER_RESOURCE_SET: "true"

Expand Down
30 changes: 24 additions & 6 deletions e2e/data/infrastructure-kubernetes/cluster-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ spec:
infrastructureRef:
apiVersion: infrastructure.lukeaddison.co.uk/v1alpha3
kind: KubernetesMachineTemplate
name: ${CLUSTER_NAME}
name: ${CLUSTER_NAME}-worker
version: ${KUBERNETES_VERSION}
---
apiVersion: cluster.x-k8s.io/v1alpha3
Expand Down Expand Up @@ -102,7 +102,7 @@ spec:
infrastructureTemplate:
apiVersion: infrastructure.lukeaddison.co.uk/v1alpha3
kind: KubernetesMachineTemplate
name: ${CLUSTER_NAME}
name: ${CLUSTER_NAME}-controller
kubeadmConfigSpec:
clusterConfiguration:
controllerManager:
Expand All @@ -128,21 +128,39 @@ kind: KubernetesCluster
metadata:
name: ${CLUSTER_NAME}
spec:
controlPlaneServiceType: ${KUBERNETES_CONTROL_PLANE_SERVICE_TYPE:="ClusterIP"}
controlPlaneServiceType: ${KUBERNETES_CONTROL_PLANE_SERVICE_TYPE}
---
apiVersion: infrastructure.lukeaddison.co.uk/v1alpha3
kind: KubernetesMachineTemplate
metadata:
name: ${CLUSTER_NAME}
name: ${CLUSTER_NAME}-controller
spec:
template:
spec:
containers:
- name: kind
resources:
requests:
cpu: ${KUBERNETES_CONTROLLER_MACHINE_CPU_REQUEST:="0"}
memory: ${KUBERNETES_CONTROLLER_MACHINE_MEMORY_REQUEST:="0"}
dnsConfig:
nameservers:
- 8.8.8.8
- 8.8.4.4
---
apiVersion: infrastructure.lukeaddison.co.uk/v1alpha3
kind: KubernetesMachineTemplate
metadata:
name: ${CLUSTER_NAME}-worker
spec:
template:
spec:
containers:
- name: kind
resources:
requests:
cpu: ${KUBERNETES_CONTROL_PLANE_MACHINE_CPU_REQUESTS:="0"}
memory: ${KUBERNETES_CONTROL_PLANE_MACHINE_MEMORY_REQUESTS:="0"}
cpu: ${KUBERNETES_WORKER_MACHINE_CPU_REQUEST:="0"}
memory: ${KUBERNETES_WORKER_MACHINE_MEMORY_REQUEST:="0"}
dnsConfig:
nameservers:
- 8.8.8.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: KubernetesCluster
metadata:
name: ${CLUSTER_NAME}
spec:
controlPlaneServiceType: ${KUBERNETES_CONTROL_PLANE_SERVICE_TYPE:="ClusterIP"}
controlPlaneServiceType: ${KUBERNETES_CONTROL_PLANE_SERVICE_TYPE}
---
apiVersion: cluster.x-k8s.io/v1alpha3
kind: Cluster
Expand All @@ -29,16 +29,16 @@ spec:
apiVersion: infrastructure.lukeaddison.co.uk/v1alpha3
kind: KubernetesMachineTemplate
metadata:
name: ${CLUSTER_NAME}
name: ${CLUSTER_NAME}-controller
spec:
template:
spec:
containers:
- name: kind
resources:
requests:
cpu: ${KUBERNETES_CONTROL_PLANE_MACHINE_CPU_REQUESTS:="0"}
memory: ${KUBERNETES_CONTROL_PLANE_MACHINE_MEMORY_REQUESTS:="0"}
cpu: ${KUBERNETES_CONTROLLER_MACHINE_CPU_REQUEST:="0"}
memory: ${KUBERNETES_CONTROLLER_MACHINE_MEMORY_REQUEST:="0"}
---
apiVersion: controlplane.cluster.x-k8s.io/v1alpha3
kind: KubeadmControlPlane
Expand All @@ -50,7 +50,7 @@ spec:
infrastructureTemplate:
apiVersion: infrastructure.lukeaddison.co.uk/v1alpha3
kind: KubernetesMachineTemplate
name: ${CLUSTER_NAME}
name: ${CLUSTER_NAME}-controller
kubeadmConfigSpec:
initConfiguration:
nodeRegistration:
Expand Down Expand Up @@ -83,6 +83,20 @@ spec:
cgroups-per-qos: "false"
enforce-node-allocatable: ""
---
apiVersion: infrastructure.lukeaddison.co.uk/v1alpha3
kind: KubernetesMachineTemplate
metadata:
name: ${CLUSTER_NAME}-worker
spec:
template:
spec:
containers:
- name: kind
resources:
requests:
cpu: ${KUBERNETES_WORKER_MACHINE_CPU_REQUEST:="0"}
memory: ${KUBERNETES_WORKER_MACHINE_MEMORY_REQUEST:="0"}
---
apiVersion: cluster.x-k8s.io/v1alpha3
kind: MachineDeployment
metadata:
Expand All @@ -103,7 +117,7 @@ spec:
kind: KubeadmConfigTemplate
infrastructureRef:
apiVersion: infrastructure.lukeaddison.co.uk/v1alpha3
name: ${CLUSTER_NAME}
name: ${CLUSTER_NAME}-worker
kind: KubernetesMachineTemplate
---
apiVersion: cluster.x-k8s.io/v1alpha3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,19 @@ patchesStrategicMerge:
apiVersion: infrastructure.lukeaddison.co.uk/v1alpha3
kind: KubernetesMachineTemplate
metadata:
name: ${CLUSTER_NAME}
name: ${CLUSTER_NAME}-controller
spec:
template:
spec:
dnsConfig:
nameservers:
- 8.8.8.8
- 8.8.4.4
- |-
apiVersion: infrastructure.lukeaddison.co.uk/v1alpha3
kind: KubernetesMachineTemplate
metadata:
name: ${CLUSTER_NAME}-worker
spec:
template:
spec:
Expand Down
17 changes: 9 additions & 8 deletions release/cluster-template-persistent-control-plane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: KubernetesCluster
metadata:
name: ${CLUSTER_NAME}
spec:
controlPlaneServiceType: ${KUBERNETES_CONTROL_PLANE_SERVICE_TYPE:="ClusterIP"}
controlPlaneServiceType: ${KUBERNETES_CONTROL_PLANE_SERVICE_TYPE}
---
apiVersion: cluster.x-k8s.io/v1alpha3
kind: Cluster
Expand Down Expand Up @@ -38,27 +38,28 @@ spec:
- name: kind
resources:
requests:
cpu: ${KUBERNETES_CONTROL_PLANE_MACHINE_CPU_REQUESTS:="0"}
memory: ${KUBERNETES_CONTROL_PLANE_MACHINE_MEMORY_REQUESTS:="0"}
cpu: ${KUBERNETES_CONTROLLER_MACHINE_CPU_REQUEST:="0"}
memory: ${KUBERNETES_CONTROLLER_MACHINE_MEMORY_REQUEST:="0"}
volumeMounts:
- name: var-lib-etcd
mountPath: /var/lib/etcd
volumeClaimTemplates:
- metadata:
name: var-lib-etcd
spec:
storageClassName: ${ETCD_STORAGE_CLASS_NAME}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: ${ETCD_STORAGE_SIZE:=10Gi}
storage: ${ETCD_STORAGE_SIZE}
---
apiVersion: controlplane.cluster.x-k8s.io/v1alpha3
kind: KubeadmControlPlane
metadata:
name: ${CLUSTER_NAME}
spec:
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
replicas: ${CONTROL_PLANE_MACHINE_COUNT:="1"}
version: ${KUBERNETES_VERSION}
infrastructureTemplate:
apiVersion: infrastructure.lukeaddison.co.uk/v1alpha3
Expand Down Expand Up @@ -107,16 +108,16 @@ spec:
- name: kind
resources:
requests:
cpu: ${KUBERNETES_NODE_MACHINE_CPU_REQUESTS:="0"}
memory: ${KUBERNETES_NODE_MACHINE_MEMORY_REQUESTS:="0"}
cpu: ${KUBERNETES_WORKER_MACHINE_CPU_REQUEST:="0"}
memory: ${KUBERNETES_WORKER_MACHINE_MEMORY_REQUEST:="0"}
---
apiVersion: cluster.x-k8s.io/v1alpha3
kind: MachineDeployment
metadata:
name: ${CLUSTER_NAME}
spec:
clusterName: ${CLUSTER_NAME}
replicas: ${WORKER_MACHINE_COUNT}
replicas: ${WORKER_MACHINE_COUNT:="1"}
selector:
matchLabels:
template:
Expand Down
26 changes: 20 additions & 6 deletions release/cluster-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: KubernetesCluster
metadata:
name: ${CLUSTER_NAME}
spec:
controlPlaneServiceType: ${KUBERNETES_CONTROL_PLANE_SERVICE_TYPE:="ClusterIP"}
controlPlaneServiceType: ${KUBERNETES_CONTROL_PLANE_SERVICE_TYPE}
---
apiVersion: cluster.x-k8s.io/v1alpha3
kind: Cluster
Expand All @@ -29,16 +29,16 @@ spec:
apiVersion: infrastructure.lukeaddison.co.uk/v1alpha3
kind: KubernetesMachineTemplate
metadata:
name: ${CLUSTER_NAME}
name: ${CLUSTER_NAME}-controller
spec:
template:
spec:
containers:
- name: kind
resources:
requests:
cpu: ${KUBERNETES_CONTROL_PLANE_MACHINE_CPU_REQUESTS:="0"}
memory: ${KUBERNETES_CONTROL_PLANE_MACHINE_MEMORY_REQUESTS:="0"}
cpu: ${KUBERNETES_CONTROLLER_MACHINE_CPU_REQUEST:="0"}
memory: ${KUBERNETES_CONTROLLER_MACHINE_MEMORY_REQUEST:="0"}
---
apiVersion: controlplane.cluster.x-k8s.io/v1alpha3
kind: KubeadmControlPlane
Expand All @@ -50,7 +50,7 @@ spec:
infrastructureTemplate:
apiVersion: infrastructure.lukeaddison.co.uk/v1alpha3
kind: KubernetesMachineTemplate
name: ${CLUSTER_NAME}
name: ${CLUSTER_NAME}-controller
kubeadmConfigSpec:
initConfiguration:
nodeRegistration:
Expand Down Expand Up @@ -83,6 +83,20 @@ spec:
cgroups-per-qos: "false"
enforce-node-allocatable: ""
---
apiVersion: infrastructure.lukeaddison.co.uk/v1alpha3
kind: KubernetesMachineTemplate
metadata:
name: ${CLUSTER_NAME}-worker
spec:
template:
spec:
containers:
- name: kind
resources:
requests:
cpu: ${KUBERNETES_WORKER_MACHINE_CPU_REQUEST:="0"}
memory: ${KUBERNETES_WORKER_MACHINE_MEMORY_REQUEST:="0"}
---
apiVersion: cluster.x-k8s.io/v1alpha3
kind: MachineDeployment
metadata:
Expand All @@ -103,7 +117,7 @@ spec:
kind: KubeadmConfigTemplate
infrastructureRef:
apiVersion: infrastructure.lukeaddison.co.uk/v1alpha3
name: ${CLUSTER_NAME}
name: ${CLUSTER_NAME}-worker
kind: KubernetesMachineTemplate
---
apiVersion: cluster.x-k8s.io/v1alpha3
Expand Down

0 comments on commit 0af034e

Please sign in to comment.