POC of cluster api using Docker in Docker
Quick notes taken during the creation of the cluster-api-provider-dind scaffolding creation
Install dep
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
sudo mv $HOME/bin/dep /usr/bin
Install kustomize
wget https://github.com/kubernetes-sigs/kustomize/releases/download/v1.0.11/kustomize_1.0.11_linux_amd64
mv kustomize_1.0.11_linux_amd64 kustomize
chmod +x kustomize
sudo mv kustomize /usr/bin/
Install kubebuilder (contains a copy of kubectl, etcd and kubeapi-server)
wget https://github.com/kubernetes-sigs/kubebuilder/releases/download/v1.0.8/kubebuilder_1.0.8_linux_amd64.tar.gz
tar xvf kubebuilder_1.0.8_linux_amd64.tar.gz
mv kubebuilder_1.0.8_linux_amd64 kubebuilder
sudo mv kubebuilder /usr/local
Ensure the local kubelete and kubernetes cluster is stopped
sudo systemctl stop kubelet
docker stop $(docker ps -qa)
export PATH=$PATH:/usr/local/kubebuilder/bin
cd cluster-api-provider-dind/
kubebuilder init --domain kubekit.cloud --license apache2 --owner "The Kubernetes Authors"
git add .
git commit -m "Generate scaffolding."
git push
kubebuilder create api --group dind --version v1alpha1 --kind AirshipClusterProviderSpec
kubebuilder create api --group dind --version v1alpha1 --kind AirshipClusterProviderStatus
kubebuilder create api --group dind --version v1alpha1 --kind AirshipMachineProviderStatus
kubebuilder create api --group dind --version v1alpha1 --kind AirshipMachineProviderSpec
vi cmd/manager/main.go
mkdir -p pkg/cloud/dind/actuators/cluster/
mkdir -p pkg/cloud/dind/actuators/machine/
vi pkg/cloud/dind/actuators/cluster/actuator.go
vi pkg/cloud/dind/actuators/machine/actuator.go
vi pkg/controller/add_cluster_controller.go
vi pkg/controller/add_machine_controller.go
vi Makefile
dep ensure
export IMG=kubekit99/cluster-api-provider-dind
dep ensure
make
make docker-build IMG=${IMG}
git add .
git commit -m "Add CRDs and build image"
git push
If you used brute force, git add . the repository becomes bulky. In order to keep the scrict minimum
git rm -fr vendor/
git rm -fr bin/
git commit
git push origin --force --all
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch vendor" HEAD
git push origin --force --all
git clone https://github.com/kubekit99/cluster-api-provider-dind.git
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch bin" HEAD
git push origin --force --all
git clone https://github.com/kubekit99/cluster-api-provider-dind.git
List of commands used to rebuild and publish the images.
export IMG=kubekit99/cluster-api-provider-dind
dep ensure
make
make docker-build IMG=${IMG}
make docker-push IMG=${IMG}
List of commands to deploy and test.
Ensure that /usr/local/kubebuilder is no longer in your path if you are using the same machine
kubectl get nodes
kubectl apply -f provider-components.yaml
kubectl get all --all-namespaces
kubectl logs pod/cluster-api-provider-dind-controller-manager-0 -n cluster-api-provider-dind-system manager
TBD