Add control plane deployment

K8s control plane is deployed by KubeadmControlPlane controller. This
controller creates CAPI machines and infrastructure objects
(Metal3Machine). Metal3Machine objects are created based on a template
which contins host selector label. Control plane label is assigned to a
particular BareMetalHots object defined inside of the shared
kustomization.

Relates-To: #149
Closes: #221
Change-Id: I3be1750aacf9736ece2944045c036f405e404561
This commit is contained in:
Dmitry Ukov
2020-03-24 23:30:57 +04:00
parent fbaed0b7c8
commit df2fff0acf
29 changed files with 512 additions and 13 deletions

View File

@@ -55,3 +55,5 @@ tftp_root = /shared/tftpboot
uefi_pxe_config_template = $pybasedir/drivers/modules/ipxe_config.template
[redfish]
use_swift = false
[service_catalog]
endpoint_override = http://$(PROVISIONING_IP):6385

View File

@@ -0,0 +1,30 @@
---
apiVersion: cluster.x-k8s.io/v1alpha3
kind: Cluster
metadata:
name: target-cluster
spec:
clusterNetwork:
services:
cidrBlocks: ["10.96.0.0/12"]
pods:
cidrBlocks: ["192.168.0.0/18"]
serviceDomain: "cluster.local"
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
kind: Metal3Cluster
name: target-cluster
controlPlaneRef:
kind: KubeadmControlPlane
apiVersion: controlplane.cluster.x-k8s.io/v1alpha3
name: cluster-controlplane
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
kind: Metal3Cluster
metadata:
name: target-cluster
spec:
controlPlaneEndpoint:
host: 10.23.25.102
port: 6443
noCloudProvider: true

View File

@@ -0,0 +1,52 @@
kind: KubeadmControlPlane
apiVersion: controlplane.cluster.x-k8s.io/v1alpha3
metadata:
name: cluster-controlplane
spec:
replicas: 1
version: v1.17.0
infrastructureTemplate:
kind: Metal3MachineTemplate
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
name: cluster-controlplane
kubeadmConfigSpec:
preKubeadmCommands:
- wget -O "/usr/bin/konfigadm" https://github.com/flanksource/konfigadm/releases/download/v0.5.3/konfigadm && chmod +x "/usr/bin/konfigadm"
- konfigadm apply --config=/konfigadm.yml
initConfiguration:
nodeRegistration:
name: '{{ ds.meta_data.local_hostname }}'
kubeletExtraArgs:
node-labels: 'metal3.io/uuid={{ ds.meta_data.uuid }}'
joinConfiguration:
controlPlane: {}
nodeRegistration:
name: '{{ ds.meta_data.local_hostname }}'
kubeletExtraArgs:
node-labels: 'metal3.io/uuid={{ ds.meta_data.uuid }}'
postKubeadmCommands:
- kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f https://docs.projectcalico.org/v3.9/manifests/calico.yaml
files:
- path: /konfigadm.yml
owner: root:root
permissions: "0640"
content: |
kubernetes:
version: 1.17.3
container_runtime:
type: docker
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
kind: Metal3MachineTemplate
metadata:
name: cluster-controlplane
spec:
template:
spec:
image:
# NOTE (dukov) this should be overridden on lower levels
url: https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img
checksum: 4a6909d1480ac30d676accd7b37ec711
hostSelector:
matchLabels:
airshipit.org/k8s-role: controlplane-host

View File

@@ -0,0 +1,3 @@
resources:
- cluster.yaml
- controlplane.yaml

View File

@@ -0,0 +1,11 @@
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
kind: Metal3MachineTemplate
metadata:
name: cluster-controlplane
spec:
template:
spec:
image:
url: http://10.23.24.1:8099/target-image.qcow2
checksum: http://10.23.24.1:8099/target-image.qcow2.md5sum

View File

@@ -0,0 +1,9 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
# TODO (dukov) It's recocommended to upload BareMetalHost objects separately
# otherwise nodes will hang in 'registering' state for quite a long time
- nodes
- ../../../../function/k8scontrol
patchesStrategicMerge:
- control-machine-template-patch.yaml

View File

@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../shared/baremetalhost/node01
commonLabels:
airshipit.org/k8s-role: controlplane-host

View File

@@ -0,0 +1,14 @@
---
apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
name: node01
spec:
bmc:
address: redfish+http://10.23.25.1:8000/redfish/v1/Systems/air-target-1
credentialsName: node01-bmc
online: false
bootMACAddress: 52:54:00:b6:ed:31
networkData:
name: node01-netdata
namespace: default

View File

@@ -0,0 +1,16 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- baremetalhost.yaml
generatorOptions:
disableNameSuffixHash: true
secretGenerator:
- name: node01-netdata
files:
- networkData
- name: node01-bmc
literals:
- username=root
- password=r00tme

View File

@@ -0,0 +1,31 @@
links:
- id: oam0
name: oam0
type: phy
ethernet_mac_address: 52:54:00:9b:27:4c
mtu: "1500"
- id: pxe0
name: pxe0
type: phy
ethernet_mac_address: 52:54:00:b6:ed:31
mtu: "1500"
networks:
- id: private-ipv4
type: ipv4
link: oam0
ip_address: 10.23.25.102
netmask: 255.255.255.0
routes:
- network: 0.0.0.0
netmask: 0.0.0.0
gateway: 10.23.25.1
- id: private-ipv4
type: ipv4
link: pxe0
ip_address: 10.23.24.102
netmask: 255.255.255.0
services:
- address: 8.8.8.8
type: dns
- address: 8.8.4.4
type: dns