There are several mage targets exposed under the k8s namespace that can be
used to automate many setup/configuration steps for several k8s flavors.
Refer to the mage documentation if you do not have mage installed.
To see which flavors of k8s that we support with this set of mage targets, run:
mage k8s:listSupportedFlavorsA supported flavor can then be used by setting the M_K8S_FLAVOR env variable to that
flavor, for example:
M_K8S_FLAVOR=kindIf the M_K8S_FLAVOR is not specified, the default flavor becomes k3d
Note: Some flavors do not currently support every k8s mage target. Some targets may print output explaining that manual steps may need to be taken in some cases, and in others an error will be thrown.
There are certain env variables that can be used acrossed different k8s flavors,
but there could be many that are flavor-specific. Because of this, the env target
could print out different information depending on what flavor you choose.
Example usage:
M_K8S_FLAVOR=gke mage k8s:envCLI tools for supported flavors can be installed by running the installTool target.
Example usage:
M_K8S_FLAVOR=kind mage k8s:installToolA mage target can be invoked to stand up a new k8s cluster, along with a sample datacenter and the Operator. This will attempt to delete an existing cluster if there is one.
For Apache Cassandra:
M_K8S_FLAVOR=k3d mage k8s:setupCassandraClusterFor DSE:
M_K8S_FLAVOR=k3d mage k8s:SetupDSEClusterThe resource files that get loaded into the cluster with this target are:
operator/deploy/kind/rancher-local-path-storage.yaml,
operator/deploy/role.yaml,
operator/deploy/role_binding.yaml,
operator/deploy/service_account.yaml,
operator/deploy/crds/cassandra.datastax.com_cassandradatacenters_crd.yaml,
operator/deploy/operator.yaml,
# if using dse
operator/example-cassdc-yaml/dse-6.8.x/example-cassdc-minimal.yaml
# if using cassandra
operator/example-cassdc-yaml/cassandra-3.11.x/example-cassdc-minimal.yamlTo check the cluster status:
kubectl get pods
kubectl describe pod clstr-dtcntr-r0-sts-0To connect to the cluster:
kubectl exec -it clstr-dtcntr-r0-sts-0 -- /bin/bashTo invoke cqlsh:
cqlsh /tmp/dse.sockTo delete the cluster:
mage k8s:deleteClusterFor k8s flavors that run their workers inside of docker (KIND, k3d), there is a mage target that will remove the existing operator image from every Docker container in the cluster and then rebuild/reload the operator Docker image into those worker containers.
This will need to be done after every code change of the operator code!
M_K8S_FLAVOR=k3d mage k8s:reloadOperatorPlease make sure to stop any running pods of the operator before reloading the image.
After your k8s cluster has been created, you can configure kubectl to point to it.
M_K8S_FLAVOR=k3d mage k8s:kubeconfigNote: this target currently assumes that you are using bash. Different shells may require manual configuration for the kubeconfig