Cluster API Templates
Describes Kubernetes Cluster API template files in Oracle CNE.
A default OCI cluster can be created
using the oci
provider with no extra arguments. For
example:
ocne cluster start --provider oci
The default cluster settings create a useful cluster, but, it's likely that extra configuration is required. To customize a deployment, generate a cluster template to use as a basis for the cluster.
The ocne cluster template
command is used to create a
cluster template, and uses the default configuration and any cluster
configuration you set to generate the template. It also fetches things such
as compute image OCIDs from the configured compartment automatically. You
can create a cluster template and save it to a file, for example:
ocne cluster template > mytemplate.yaml
The resulting YAML file contains the Cluster Resources for the Kubernetes Cluster API to create a cluster, using all the configuration you have on the local system.
For example, you could create a cluster configuration file (named
myconfig.yaml
in this example) that includes
customization to the deployment, and might include:
provider: oci
name: mycluster
controlPlaneNodes: 3
workerNodes: 3
clusterDefinition: /home/username/mytemplate.yaml
providers:
oci:
compartment: ocid1.compartment.oc1..uniqueID
In this example, the clusterDefinition
file is the
location of a Kubernetes Cluster API template, which is generated based on
the configuration in this cluster configuration file. You use the template
when you create the cluster. You can update the cluster template to use this
new configuration by running the ocne cluster template
command again and providing the configuration file. For example:
ocne cluster template --config myconfig.yaml > $HOME/mytemplate.yaml
Edit the template file to configure any Kubernetes Cluster API options
that aren't provided in a cluster configuration file. When you're satisfied
with the template, create the cluster using the cluster configuration file.
As this cluster configuration file includes a link to the cluster template
in the clusterDefinition
, the template is used to create
the cluster. For example:
ocne cluster start --config myconfig.yaml
Cluster API Template Files
Describes Kubernetes Cluster API template file contents.
A Kubernetes Cluster API template file can be generated that contains
all the information required to create a Kubernetes cluster using the Kubernetes Cluster
API. The ocne cluster template
command is used to create this file. Save
and edit this template to create clusters using the Kubernetes Cluster API.
Optionally, edit the Custom Resources in the template to suit the cluster you want to create. The options available are described in the upstream Kubernetes Cluster API Provider for Oracle Cloud Infrastructure documentation.
The template file contains Custom Resources for each component of a cluster, and includes:
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
labels:
cluster.x-k8s.io/cluster-name: "ocne"
name: "ocne"
namespace: "ocne"
spec:
...
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: OCICluster
metadata:
labels:
cluster.x-k8s.io/cluster-name: "ocne"
name: "ocne"
namespace: "ocne"
spec:
...
---
kind: KubeadmControlPlane
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
metadata:
name: "ocne-control-plane"
namespace: "ocne"
spec:
...
---
kind: OCIMachineTemplate
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
metadata:
name: "ocne-control-plane"
namespace: "ocne"
spec:
...
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: OCIMachineTemplate
metadata:
name: "ocne-md-0"
namespace: "ocne"
spec:
...
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: "ocne-md-0"
namespace: "ocne"
spec:
...
Creating a Cluster API Template
Create a Kubernetes Cluster API template using the ocne cluster
template
command.
A Kubernetes Cluster API template can be used when deploying clusters using the Kubernetes Cluster API.
You can generate a Cluster API template using the defaults set on the local system, or using a cluster configuration file.
Using an Existing VCN
Edit a Cluster API template to use an existing OCI Virtual Cloud Network (VCN).
To use an existing VCN when deploying a Kubernetes cluster to OCI, generate and edit a Cluster API template to include the VCN information. You need to provide OCIDs for:
-
VCN. The VCN to use for the cluster nodes.
-
Network Security Group. This is the network security group that contains the ingress rules to the VCN.
-
Subnet. This is the subnet of the VCN.
The values provided for the VCN and subnet are also used by the OCI Cloud Controller Manager during deployment to configure the control plane load balancer.