Skip to content

Latest commit

 

History

History
228 lines (182 loc) · 9.03 KB

get-started-with-clusterctl.md

File metadata and controls

228 lines (182 loc) · 9.03 KB

Prerequisite

Deploy Cluster Api

Clone

Please clone the project:

git clone https://github.com/outscale-dev/cluster-api-provider-outscale

If you use your own cluster for production (with backup, disaster recovery, ...) and expose it:

 export KUBECONFIG=<...>

Or you can use kind (only for local dev): Create kind:

   kind create cluster

Check cluster is ready:

   kubectl cluster-info

Install clusterctl

⚠️ In order to install tools (clusterctl, ...) with makefile, you need to have installed golang to download binaries golang You can install clusterctl for linux with:

  make install-clusterctl

Or you can install clusterctl with the clusterctl section (cluster-api). And check version which is already installed:

./bin/clusterctl version
clusterctl version: &version.Info{Major:"1", Minor:"2", GitVersion:"v1.2.4", GitCommit:"8b5cd363e11b023c2b67a1937a2af680ead9e35c", GitTreeState:"clean", BuildDate:"2022-10-17T13:37:39Z", GoVersion:"go1.18.7", Compiler:"gc", Platform:"linux/amd64"}

Initialize clusterctl

You can enable clusterresourceset with

export EXP_CLUSTER_RESOURCE_SET=true

Please create $HOME/.cluster-api/clusterctl.yaml:

providers:
- name: outscale
  type: InfrastructureProvider
  url: https://github.com/outscale/cluster-api-provider-outscale/releases/latest/infrastructure-components.yaml

You can initialize clusterctl with credential with:

export OSC_ACCESS_KEY=<your-access-key>
export OSC_SECRET_KEY=<your-secret-access-key>
export OSC_REGION=<your-region>
make credential
./bin/clusterctl init --infrastructure outscale

Create our cluster

Launch your stack with clusterctl

You can create a keypair before if you want. You can access nodes shell (with openlens, lens, ...) You have to set:

export OSC_IOPS=<osc-iops>
export OSC_VOLUME_SIZE=<osc-volume-size>
export OSC_VOLUME_TYPE=<osc-volume-type>
export OSC_KEYPAIR_NAME=<osc-keypairname>
export OSC_SUBREGION_NAME=<osc-subregion>
export OSC_VM_TYPE=<osc-vm-type>
export OSC_IMAGE_NAME=<osc-image-name>

Then you will generate:

./bin/clusterctl generate cluster <cluster-name>   --kubernetes-version <kubernetes-version>   --control-plane-machine-count=<control-plane-machine-count>   --worker-machine-count=<worker-machine-count> > getstarted.yaml

WARNING: Kubernetes version must match the kubernetes version which is included in image name in omi

You can then change to get what you want which is based on doc.

Then apply:

kubectl apply -f getstarted.yaml

Add security group rule after

You can add security group rule if you set extraSecurityGroupRule = true after you have already create a cluster and you want to set new security group rule.

apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: OscCluster
metadata:
  name: cluster-api
  namespace: default
spec:
  network:
    extraSecurityGroupRule: false

Add a public ip after bastion is created

You can add a public ip if you set publicIpNameAfterBastion = true after you have already create a cluster with a bastion.

apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: OscCluster
metadata:
  name: cluster-api
  namespace: default
spec:
  network:
  ...
    bastion:
    ..
      publicIpNameAfterBastion: true

Get Kubeconfig

You can then get the status:

root@cidev-admin v1beta1]# kubectl get cluster-api  -A
NAMESPACE   NAME                                                                       CLUSTER       AGE
default     kubeadmconfig.bootstrap.cluster.x-k8s.io/cluster-api-control-plane-lzj65   cluster-api   95m
default     kubeadmconfig.bootstrap.cluster.x-k8s.io/cluster-api-md-0-zgx4w            cluster-api   95m

NAMESPACE   NAME                                                                AGE
default     kubeadmconfigtemplate.bootstrap.cluster.x-k8s.io/cluster-api-md-0   95m

NAMESPACE   NAME                                                      CLUSTER       REPLICAS   READY   AVAILABLE   AGE   VERSION
default     machineset.cluster.x-k8s.io/cluster-api-md-0-7568fb659d   cluster-api   1                              95m   v1.22.11

NAMESPACE   NAME                                                  CLUSTER       REPLICAS   READY   UPDATED   UNAVAILABLE   PHASE       AGE   VERSION
default     machinedeployment.cluster.x-k8s.io/cluster-api-md-0   cluster-api   1                  1         1             ScalingUp   95m   v1.22.11

NAMESPACE   NAME                                                         CLUSTER       NODENAME                                  PROVIDERID         PHASE      AGE   VERSION
default     machine.cluster.x-k8s.io/cluster-api-control-plane-4q2s8     cluster-api   ip-10-0-0-45.eu-west-2.compute.internal   aws:///eu-west-2a/i-3b629324    Running    95m   v1.22.11
default     machine.cluster.x-k8s.io/cluster-api-md-0-7568fb659d-hnkfw   cluster-api   ip-10-0-0-144.eu-west-2.compute.internal   aws:///eu-west-2a/i-add154be   Running    95m   v1.22.11

NAMESPACE   NAME                                   PHASE         AGE   VERSION
default     cluster.cluster.x-k8s.io/cluster-api   Provisioned   95m   

NAMESPACE                           NAME                                                         AGE   TYPE                   PROVIDER      VERSION
capi-kubeadm-bootstrap-system       provider.clusterctl.cluster.x-k8s.io/bootstrap-kubeadm       46h   BootstrapProvider      kubeadm       v1.2.1
capi-kubeadm-control-plane-system   provider.clusterctl.cluster.x-k8s.io/control-plane-kubeadm   46h   ControlPlaneProvider   kubeadm       v1.2.1
capi-system                         provider.clusterctl.cluster.x-k8s.io/cluster-api             46h   CoreProvider           cluster-api   v1.2.1

NAMESPACE   NAME                                                                          CLUSTER       INITIALIZED   API SERVER AVAILABLE   REPLICAS   READY   UPDATED   UNAVAILABLE   AGE   VERSION
default     kubeadmcontrolplane.controlplane.cluster.x-k8s.io/cluster-api-control-plane   cluster-api                                        1                  1         1             95m   v1.22.11

NAMESPACE   NAME                                                                           AGE
default     oscmachinetemplate.infrastructure.cluster.x-k8s.io/cluster-api-control-plane   95m
default     oscmachinetemplate.infrastructure.cluster.x-k8s.io/cluster-api-md-0            95m

Get kubeconfig

In order to get kubeconfig please use: kubeconfig

Node Ready

In order to have node ready, you must have a CNI and CCM.

You can use clusterresourceset with label clustername + crs-cni and label clustername + crs-ccm where clustername is the name of your cluster.

To install cni you can use helm charts or clusteresourceset.

To install helm,please follow helm

A list of cni:

To install ccm, you can use helm charts or clusteresourceset.

Delete Cluster api

Delete cluster

To delete our cluster:

kubectl delete -f getstarted.yaml

To delete cluster-api:

clusterctl delete --all