|
1 | | -# cluster-stack-provider-openstack |
| 1 | +# Cluster Stack Provider OpenStack |
| 2 | + |
| 3 | +[](https://github.com/SovereignCloudStack/cluster-stack-provider-openstack/releases) |
| 4 | +[](https://goreportcard.com/report/github.com/sovereignCloudStack/cluster-stack-provider-openstack) |
| 5 | +[](https://opensource.org/licenses/Apache-2.0) |
| 6 | + |
| 7 | +The Cluster Stack Provider OpenStack (CSPO) works with the Cluster Stack Operator (CSO) and Cluster Stacks, enabling the creation of Kubernetes clusters in a Cluster-API-native (CAPI) fashion. |
| 8 | + |
| 9 | +The primary goal of the CSPO is to facilitate the import of node images in a manner specific to OpenStack. These images are then used to create Kubernetes workload clusters on top of the OpenStack infrastructure. |
| 10 | + |
| 11 | +To gain a comprehensive understanding of the entire concept, we recommend familiarizing yourself with the fundamental [concepts](https://github.com/SovereignCloudStack/cluster-stack-operator/blob/main/docs/concept.md) and [architecture](https://github.com/SovereignCloudStack/cluster-stack-operator/blob/main/docs/architecture/overview.md) outlined in [CSO](https://github.com/SovereignCloudStack/cluster-stack-operator/blob/main/README.md) and [Cluster Stacks](https://github.com/SovereignCloudStack/cluster-stacks/blob/main/README.md). |
| 12 | + |
| 13 | +# Quickstart Guide |
| 14 | + |
| 15 | +This section guides you through all the necessary steps to create a workload Kubernetes cluster on top of the OpenStack infrastructure. The guide describes a path that utilizes the [clusterctl] CLI tool to manage the lifecycle of a CAPI management cluster and employs [kind] to create a local non-production management cluster. |
| 16 | + |
| 17 | +Note that it is a common practice to create a temporary, local [bootstrap cluster](https://cluster-api.sigs.k8s.io/reference/glossary#bootstrap-cluster) which is then used to provision a target [management cluster](https://cluster-api.sigs.k8s.io/reference/glossary#management-cluster) on the selected infrastructure. |
| 18 | + |
| 19 | +## Prerequisites |
| 20 | + |
| 21 | +- Install [Docker] and [kind] |
| 22 | +- Install [kubectl] |
| 23 | +- Install [Helm] |
| 24 | +- Install [clusterctl] |
| 25 | +- Install [go] # installation of the Go package `envsubst` is required to enable the expansion of variables specified in CSPO and CSO manifests. |
| 26 | + |
| 27 | +## Initialize the management cluster |
| 28 | + |
| 29 | +Create the kind cluster: |
| 30 | + |
| 31 | +```bash |
| 32 | +kind create cluster |
| 33 | +``` |
| 34 | + |
| 35 | +Transform the Kubernetes cluster into a management cluster by using `clusterctl init` and bootstrap it with CAPI and Cluster API Provider OpenStack ([CAPO]) components: |
| 36 | + |
| 37 | +```bash |
| 38 | +# Enable Cluster Class CAPI experimental feature |
| 39 | +export CLUSTER_TOPOLOGY=true |
| 40 | + |
| 41 | +# Install CAPI and CAPO components |
| 42 | +clusterctl init --infrastructure openstack |
| 43 | +``` |
| 44 | + |
| 45 | +### Create a secret for OpenStack access |
| 46 | + |
| 47 | +To enable communication between the CSPO and the Cluster API Provider for OpenStack (CAPO) with the OpenStack API, it is necessary to generate a secret containing the access data (clouds.yaml). |
| 48 | +Ensure that this secret is located in the identical namespace as the other Custom Resources. |
| 49 | + |
| 50 | +```bash |
| 51 | +kubectl create secret generic <my-cloud-secret> --from-file=clouds.yaml=path/to/clouds.yaml |
| 52 | + |
| 53 | +# Patch the created secrets so they are automatically moved to the target cluster later. |
| 54 | + |
| 55 | +kubectl patch secret <my-cloud-secret> -p '{"metadata":{"labels":{"clusterctl.cluster.x-k8s.io/move":""}}}' |
| 56 | +``` |
| 57 | + |
| 58 | +### CSO and CSPO variables preparation |
| 59 | + |
| 60 | +The CSO and CSPO must be directed to the Cluster Stacks repository housing releases for the OpenStack provider. |
| 61 | +Modify and export the following environment variables if you wish to redirect CSO and CSPO to an alternative Git repository |
| 62 | + |
| 63 | +Be aware that GitHub enforces limitations on the number of API requests per unit of time. To overcome this, |
| 64 | +it is recommended to configure a personal access token for authenticated calls. This will significantly increase the rate limit for GitHub API requests. |
| 65 | + |
| 66 | +```bash |
| 67 | +export GIT_PROVIDER_B64=Z2l0aHVi # github |
| 68 | +export GIT_ORG_NAME_B64=U292ZXJlaWduQ2xvdWRTdGFjaw== # SovereignCloudStack |
| 69 | +export GIT_REPOSITORY_NAME_B64=Y2x1c3Rlci1zdGFja3M= # cluster-stacks |
| 70 | +export GIT_ACCESS_TOKEN_B64=<my-github-access-token> |
| 71 | +``` |
| 72 | + |
| 73 | +### CSO and CSPO deployment |
| 74 | + |
| 75 | +Install the [envsubst] Go package. It is required to enable the expansion of variables specified in CSPO and CSO manifests. |
| 76 | + |
| 77 | +```bash |
| 78 | +GOBIN=/tmp go install github.com/drone/envsubst/v2/cmd/envsubst@latest |
| 79 | +``` |
| 80 | + |
| 81 | +Get the latest CSO release version and apply CSO manifests to the management cluster. |
| 82 | + |
| 83 | +```bash |
| 84 | +# Get the latest CSO release version |
| 85 | +CSO_VERSION=$(curl https://api.github.com/repos/SovereignCloudStack/cluster-stack-operator/releases/latest -s | jq .name -r) |
| 86 | +# Apply CSO manifests |
| 87 | +curl -sSL https://github.com/sovereignCloudStack/cluster-stack-operator/releases/download/${CSO_VERSION}/cso-infrastructure-components.yaml | /tmp/envsubst | kubectl apply -f - |
| 88 | +``` |
| 89 | + |
| 90 | +Get the latest CSPO release version and apply CSPO manifests to the management cluster. |
| 91 | + |
| 92 | +```bash |
| 93 | +# Get the latest CSPO release version |
| 94 | +CSPO_VERSION=$(curl https://api.github.com/repos/SovereignCloudStack/cluster-stack-provider-openstack/releases/latest -s | jq .name -r) |
| 95 | +# Apply CSPO manifests |
| 96 | +curl -sSL https://github.com/sovereignCloudStack/cluster-stack-provider-openstack/releases/download/${CSPO_VERSION}/cspo-infrastructure-components.yaml | /tmp/envsubst | kubectl apply -f - |
| 97 | +``` |
| 98 | + |
| 99 | +## Create the workload cluster |
| 100 | + |
| 101 | +To transfer the credentials stored in the mentioned secret [above](#create-a-secret-for-openstack-access) to the operator, |
| 102 | +create an `OpenStackClusterStackReleaseTemplate` object and specify this secret in the `identityRef` field. |
| 103 | +The `clouds.yaml` file may contain one or more clouds, so users must specify the desired connection to a specific cloud using the `cloudName` field. |
| 104 | +Refer to the [examples/cspotemplate.yaml](./examples/cspotemplate.yaml) file for more details. |
| 105 | + |
| 106 | +Next, apply this template to the management cluster: |
| 107 | + |
| 108 | +```bash |
| 109 | +kubectl apply -f <path-to-openstack-clusterstack-release-template> |
| 110 | +``` |
| 111 | + |
| 112 | +Proceed to apply the `ClusterStack` to the management cluster. For more details, refer to [examples/clusterstack.yaml](./examples/clusterstack.yaml): |
| 113 | + |
| 114 | +```bash |
| 115 | +kubectl apply -f <path-to-openstack-clusterstack> |
| 116 | +``` |
| 117 | + |
| 118 | +Please be patient and wait for the operator to execute the necessary tasks. |
| 119 | +If your `ClusterStack` object encounters no errors and `openstacknodeimagereleases` is ready, you can deploy a workload cluster. |
| 120 | +This can be done by applying the cluster-template. |
| 121 | +Refer to the example of this template in [examples/cluster.yaml](./examples/cluster.yaml): |
| 122 | + |
| 123 | +```bash |
| 124 | +kubectl apply -f <path-to-cluster-template> |
| 125 | +``` |
| 126 | + |
| 127 | +Utilize a convenient CLI `clusterctl` to investigate the health of the cluster: |
| 128 | + |
| 129 | +```bash |
| 130 | +clusterctl describe cluster <cluster-name> |
| 131 | +``` |
| 132 | + |
| 133 | +Once the cluster is provisioned and in good health, you can retrieve its kubeconfig and establish communication with the newly created workload cluster: |
| 134 | + |
| 135 | +```bash |
| 136 | +# Get the workload cluster kubeconfig |
| 137 | +clusterctl get kubeconfig <cluster-name> > kubeconfig.yaml |
| 138 | +# Communicate with the workload cluster |
| 139 | +kubectl --kubeconfig kubeconfig.yaml get nodes |
| 140 | +``` |
| 141 | + |
| 142 | +# Compatibility with Cluster Stack Operator |
| 143 | + |
| 144 | +| | CSO `v0.1.0-alpha.2` | |
| 145 | +| ----------------------- | -------------------- | |
| 146 | +| CSPO `v0.1.0-alpha.rc1` | ✓ | |
| 147 | + |
| 148 | +# Development guide |
| 149 | + |
| 150 | +Refer to the [doc page](./docs/develop.md) to find more information about how to develop this operator. |
| 151 | + |
| 152 | +# API Reference |
| 153 | + |
| 154 | +CSPO currently exposes the following APIs: |
| 155 | +- the CSPO Custom Resource Definitions (CRDs): [documentation](https://doc.crds.dev/github.com/SovereignCloudStack/cluster-stack-provider-openstack) |
| 156 | +- Golang APIs: tbd |
| 157 | + |
| 158 | +<!-- links --> |
| 159 | +[Docker]: https://www.docker.com/ |
| 160 | +[Helm]: https://helm.sh/docs/intro/install/ |
| 161 | +[kind]: https://kind.sigs.k8s.io/ |
| 162 | +[kubectl]: https://kubernetes.io/docs/tasks/tools/install-kubectl/ |
| 163 | +[clusterctl]: https://cluster-api.sigs.k8s.io/user/quick-start.html#install-clusterctl |
| 164 | +[CAPO]: https://github.com/kubernetes-sigs/cluster-api-provider-openstack |
| 165 | +[go]: https://go.dev/doc/install |
| 166 | +[envsubst]: https://github.com/drone/envsubst |
0 commit comments