This repository hosts a concrete implementation of an OpenStack provider for the cluster-api project.
Learn how to engage with the Kubernetes community on the community page.
You can reach the maintainers of this project at:
Participation in the Kubernetes community is governed by the Kubernetes Code of Conduct.
-
Install
kubectl
(see here). -
Install minikube, version 0.30.0 or greater.
-
Install a driver for minikube. For Linux, we recommend kvm2. For MacOS, we recommend VirtualBox.
-
An appropriately configured Go development environment
-
Build the
clusterctl
toolgit clone https://github.com/kubernetes-sigs/cluster-api-provider-openstack $GOPATH/src/sigs.k8s.io/cluster-api-provider-openstack cd $GOPATH/src/sigs.k8s.io/cluster-api-provider-openstack/cmd/clusterctl go build
-
Create the
cluster.yaml
,machines.yaml
,provider-components.yaml
, andaddons.yaml
files if needed. If you want to use the generate-yaml.sh script, then you will need kustomize version 1.0.11, which can be found at https://github.com/kubernetes-sigs/kustomize/releases/tag/v1.0.11, and the latest go implementation of yq, which can be found at https://github.com/mikefarah/yq. The script has the following usage:cd examples/openstack ./generate-yaml.sh [options] <path/to/clouds.yaml> <openstack cloud> <provider os> cd ../..
<provider os>
specifies the operating system of the virtual machines Kubernetes will run on. Supported Operating Systems:ubuntu
centos
We no longer support generating clouds.yaml. You should be able to get a valid clouds.yaml from your openstack cluster. However, make sure that the following fields are included, and correct.
username
user_domain_name
project_id
region_name
auth_url
password
You will need to make changes to the generated files to create a working cluster. You can find some guidance on what needs to be edited, and how to create some of the required OpenStack resources in the Configuration documentation.
When running
generate-yaml.sh
the first time, a new ssh keypair is generated and stored as$HOME/.ssh/openstack_tmp
and$HOME/.ssh/openstack_tmp.pub
. In order to allowclusterctl
to fetch Kubernetes'admin.conf
from the master node, you must manually create the key pair in OpenStack. By default the generatedmachine.yaml
usescluster-api-provider-openstack
to be thekeyName
. However, you are free to change that.e.g.
openstack keypair create --public-key ~/.ssh/openstack_tmp.pub cluster-api-provider-openstack
-
Create a cluster:
./clusterctl create cluster --bootstrap-type minikube --bootstrap-flags kubernetes-version=v1.12.3 --provider openstack -c examples/openstack/out/cluster.yaml -m examples/openstack/out/machines.yaml -p examples/openstack/out/provider-components.yaml
To choose a specific minikube driver, please use the --bootstrap-flags vm-driver=xxx
command line parameter. For example to use the kvm2 driver with clusterctl you woud add --bootstrap-flags vm-driver=kvm2
, for linux, if you haven't installed any driver, you can add --bootstrap-flags vm-driver=none
.
Additional advanced flags can be found via help.
./clusterctl create cluster --help
In Cluster.spec.ProviderSpec
there is a boolean option called ManagedSecurityGroups
that, if set to true
, will create a default set of security groups for the cluster. These are meant for a "standard" setup, and might not be suitable for every environment. Please review the rules below before you use them.
NOTE: For now, there is no way to automatically use these rules, which makes them a bit cumbersome to use, this will be possible in the near future.
The rules created are:
- A rule for the controlplane machine, that allows access from everywhere to port 22 and 443.
- A rule for all the machines, both the controlplane and the nodes that allow all traffic between members of this group.
Once you have created a cluster, you can interact with the cluster and machine resources using kubectl:
kubectl --kubeconfig=kubeconfig get clusters
kubectl --kubeconfig=kubeconfig get machines
kubectl --kubeconfig=kubeconfig get machines -o yaml
This guide explains how to delete all resources that were created as part of your openstack Cluster API Kubernetes cluster.
-
Delete all of the node Machines in the cluster. Make sure to wait for the corresponding Nodes to be deleted before moving onto the next step. After this step, the master node will be the only remaining node.
kubectl --kubeconfig=kubeconfig delete machines -l set=node kubectl --kubeconfig=kubeconfig get nodes
-
Delete the master machine.
kubectl --kubeconfig=kubeconfig delete machines -l set=master
-
Delete the kubeconfig file that were created for your cluster.
rm kubeconfig
-
Delete the ssh keypair that were created for your cluster machine.
rm -rf $HOME/.ssh/openstack_tmp*