oracle-cne / ocne

The Oracle Cloud Native Environment CLI
Universal Permissive License v1.0
1 stars 0 forks source link

Set cluster name and number of control plane nodes from cluster configuration file for the "ocne cluster template" command. #51

Closed prasad-shirodkar closed 2 weeks ago

prasad-shirodkar commented 2 weeks ago

Example cluster configuration file: capi.yaml

provider: oci
name: pras-cluster
workerNodes: 3
controlPlaneNodes: 3
clusterDefinition: mycluster.oci
.....
.....

Create a new ClusterAPI yaml using

ocne cluster template -c capi.yaml > mycluster.oci

Cluster name correctly set to "pras-cluster" instead of "ocne". Other references to "ocne" that correctly updated as well.

$ grep --context=10 clusterName mycluster.oci
            cloud-provider: external
            provider-id: oci://{{ ds["id"] }}
            volume-plugin-dir: "/var/lib/kubelet/volumeplugins"
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
  name: "pras-cluster-md-0"
  namespace: "pras-ns"
spec:
  clusterName: "pras-cluster"
  replicas: 3
  selector:
    matchLabels:
  template:
    spec:
      clusterName: "pras-cluster"
      version: "1.30.3"
      bootstrap:
        configRef:
          name: "pras-cluster-md-0"
          apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
          kind: KubeadmConfigTemplate
      infrastructureRef:
        name: "pras-cluster-md-0"
        apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
        kind: OCIMachineTemplate

Replicas for control plane nodes correctly set to 3.

$ grep --context=5 replicas mycluster.oci-test 
metadata:
  name: "pras-cluster-control-plane"
  namespace: "pras-ns"
spec:
  version: "1.30.3"
  replicas: 3
  machineTemplate:
    infrastructureRef:
      kind: OCIMachineTemplate
      apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
      name: "pras-cluster-control-plane"
--
metadata:
  name: "pras-cluster-md-0"
  namespace: "pras-ns"
spec:
  clusterName: "pras-cluster"
  replicas: 3
  selector:
    matchLabels:
  template:
    spec:
      clusterName: "pras-cluster"

Correct number of control planes are getting created

~ $ export KUBECONFIG=~/.kube/kubeconfig.pras-cluster 
~ $ kubectl get nodes -o wide
NAME                               STATUS   ROLES           AGE   VERSION         INTERNAL-IP      EXTERNAL-IP   OS-IMAGE                   KERNEL-VERSION                      CONTAINER-RUNTIME
pras-cluster-control-plane-hlk7s   Ready    control-plane   14h   v1.30.3+1.el8   100.101.68.155   <none>        Oracle Linux Server 8.10   5.15.0-209.161.7.2.el8uek.aarch64   cri-o://1.30.3
pras-cluster-control-plane-tnfrz   Ready    control-plane   14h   v1.30.3+1.el8   100.101.68.45    <none>        Oracle Linux Server 8.10   5.15.0-209.161.7.2.el8uek.aarch64   cri-o://1.30.3
pras-cluster-control-plane-wrt45   Ready    control-plane   14h   v1.30.3+1.el8   100.101.68.226   <none>        Oracle Linux Server 8.10   5.15.0-209.161.7.2.el8uek.aarch64   cri-o://1.30.3
pras-cluster-md-0-hw2jg-6sqxf      Ready    <none>          14h   v1.30.3+1.el8   100.101.68.125   <none>        Oracle Linux Server 8.10   5.15.0-209.161.7.2.el8uek.x86_64    cri-o://1.30.3
pras-cluster-md-0-hw2jg-klzzn      Ready    <none>          14h   v1.30.3+1.el8   100.101.68.68    <none>        Oracle Linux Server 8.10   5.15.0-209.161.7.2.el8uek.x86_64    cri-o://1.30.3
pras-cluster-md-0-hw2jg-r947d      Ready    <none>          14h   v1.30.3+1.el8   100.101.68.228   <none>        Oracle Linux Server 8.10   5.15.0-209.161.7.2.el8uek.x86_64    cri-o://1.30.3