Skip to content

Commit

Permalink
CAPI controller modification: network and reconciliation loop (#15)
Browse files Browse the repository at this point in the history
* add debug mode for manager client

* modified vm uuid string type

* refactor wait for tasks

* modify subnet spec to list for NutanixMachine

* Modify nutanix machine controller to use subnet list

* added kube-vip and subnet list to cluster-template
  • Loading branch information
yannickstruyf3 authored Apr 12, 2022
1 parent 2b5e260 commit 56f6950
Show file tree
Hide file tree
Showing 12 changed files with 748 additions and 427 deletions.
5 changes: 3 additions & 2 deletions api/v1alpha4/nutanixmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ type NutanixMachineSpec struct {
// The cluster identifier (uuid or name) can be obtained from the Prism Central console
// or using the prism_central API.
// +kubebuilder:validation:Required
Subnet NutanixResourceIdentifier `json:"subnet"`
// +kubebuilder:validation:MinItems=1
Subnets []NutanixResourceIdentifier `json:"subnet"`

// systemDiskSize is size (in Quantity format) of the system disk of the VM
// The minimum systemDiskSize is 20Gi bytes
Expand Down Expand Up @@ -94,7 +95,7 @@ type NutanixMachineStatus struct {

// The Nutanix VM's UUID
// +optional
VmUUID *string `json:"vmUUID,omitempty"`
VmUUID string `json:"vmUUID,omitempty"`

// NodeRef is a reference to the corresponding workload cluster Node if it exists.
// +optional
Expand Down
12 changes: 4 additions & 8 deletions api/v1alpha4/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions api/v1alpha4/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions api/v1beta1/nutanixmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ type NutanixMachineSpec struct {
// The cluster identifier (uuid or name) can be obtained from the Prism Central console
// or using the prism_central API.
// +kubebuilder:validation:Required
Subnet NutanixResourceIdentifier `json:"subnet"`
// +kubebuilder:validation:MinItems=1
Subnets []NutanixResourceIdentifier `json:"subnet"`

// systemDiskSize is size (in Quantity format) of the system disk of the VM
// The minimum systemDiskSize is 20Gi bytes
Expand Down Expand Up @@ -94,7 +95,7 @@ type NutanixMachineStatus struct {

// The Nutanix VM's UUID
// +optional
VmUUID *string `json:"vmUUID,omitempty"`
VmUUID string `json:"vmUUID,omitempty"`

// NodeRef is a reference to the corresponding workload cluster Node if it exists.
// +optional
Expand Down
13 changes: 7 additions & 6 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 64 additions & 3 deletions cluster-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
spec:
controlPlaneEndpoint:
host: "${CONTROL_PLANE_ENDPOINT_IP}"
port: ${CONTROLPLANE_ENDPOINT_PORT=6443}
port: ${CONTROL_PLANE_ENDPOINT_PORT=6443}

---
apiVersion: cluster.x-k8s.io/v1beta1
Expand Down Expand Up @@ -53,8 +53,8 @@ spec:
type: name
name: "${NUTANIX_PRISM_ELEMENT_CLUSTER_NAME}"
subnet:
type: name
name: "${NUTANIX_SUBNET_NAME}"
- type: name
name: "${NUTANIX_SUBNET_NAME}"

---
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
Expand All @@ -80,6 +80,66 @@ spec:
controllerManager:
extraArgs:
enable-hostpath-provisioner: "true"
files:
- content: |
apiVersion: v1
kind: Pod
metadata:
name: kube-vip
namespace: kube-system
spec:
containers:
- name: kube-vip
image: ghcr.io/kube-vip/kube-vip:v0.4.2
imagePullPolicy: IfNotPresent
args:
- manager
env:
- name: vip_arp
value: "true"
- name: address
value: "${CONTROL_PLANE_ENDPOINT_IP}"
- name: port
value: "${CONTROL_PLANE_ENDPOINT_PORT=6443}"
- name: vip_cidr
value: "32"
- name: cp_enable
value: "true"
- name: cp_namespace
value: kube-system
- name: vip_ddns
value: "false"
- name: vip_leaderelection
value: "true"
- name: vip_leaseduration
value: "15"
- name: vip_renewdeadline
value: "10"
- name: vip_retryperiod
value: "2"
securityContext:
capabilities:
add:
- NET_ADMIN
- SYS_TIME
- NET_RAW
volumeMounts:
- mountPath: /etc/kubernetes/admin.conf
name: kubeconfig
resources: {}
hostNetwork: true
hostAliases:
- hostnames:
- kubernetes
ip: 127.0.0.1
volumes:
- name: kubeconfig
hostPath:
type: FileOrCreate
path: /etc/kubernetes/admin.conf
status: {}
owner: root:root
path: /etc/kubernetes/manifests/kube-vip.yaml
initConfiguration:
nodeRegistration:
kubeletExtraArgs:
Expand All @@ -98,6 +158,7 @@ spec:
postKubeadmCommands:
- echo export KUBECONFIG=/etc/kubernetes/admin.conf >> /root/.bashrc
- echo "after kubeadm call" > /var/log/postkubeadm.log
useExperimentalRetryJoin: true
verbosity: 10

---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,27 @@ spec:
use for the Machine's VM The cluster identifier (uuid or name) can
be obtained from the Prism Central console or using the prism_central
API.
properties:
name:
description: name is the resource name in the PC
type: string
type:
description: Type is the identifier type to use for this resource.
enum:
- uuid
- name
type: string
uuid:
description: uuid is the UUID of the resource in the PC.
type: string
required:
- type
type: object
items:
description: NutanixResourceIdentifier holds the identity of a Nutanix
PC resource (cluster, image, subnet, etc.)
properties:
name:
description: name is the resource name in the PC
type: string
type:
description: Type is the identifier type to use for this resource.
enum:
- uuid
- name
type: string
uuid:
description: uuid is the UUID of the resource in the PC.
type: string
required:
- type
type: object
minItems: 1
type: array
systemDiskSize:
anyOf:
- type: integer
Expand Down Expand Up @@ -441,22 +446,27 @@ spec:
use for the Machine's VM The cluster identifier (uuid or name) can
be obtained from the Prism Central console or using the prism_central
API.
properties:
name:
description: name is the resource name in the PC
type: string
type:
description: Type is the identifier type to use for this resource.
enum:
- uuid
- name
type: string
uuid:
description: uuid is the UUID of the resource in the PC.
type: string
required:
- type
type: object
items:
description: NutanixResourceIdentifier holds the identity of a Nutanix
PC resource (cluster, image, subnet, etc.)
properties:
name:
description: name is the resource name in the PC
type: string
type:
description: Type is the identifier type to use for this resource.
enum:
- uuid
- name
type: string
uuid:
description: uuid is the UUID of the resource in the PC.
type: string
required:
- type
type: object
minItems: 1
type: array
systemDiskSize:
anyOf:
- type: integer
Expand Down
Loading

0 comments on commit 56f6950

Please sign in to comment.