GithubHelp home page GithubHelp logo

cluster-api-provider-hcloud

New project ->: https://github.com/syself/cluster-api-provider-hetzner

⚠️ Deprecation notice: We decided to archive this project and to start a fresh one out of several reasons. We wanted to re-design the structure of the project. For example, we got rid of Bazel and Packer and started with the latest skaffolding of kubebuilder. This makes it more comparable to the other provider integrations and easier to use. We are no longer accepting pull requests or providing support. We urge all cluster-api-provider-hcloud users to migrate to cluster-api-provider-hetzner as soon as possible.

Cluster API infrastructure provider for Hetzner Cloud https://hetzner.cloud

Docs

https://docs.capihc.com/ or under ./docs/src

Time estimation

Task Time
Full cluster ~15-30min
For the packer ~10-15min
Snapshot ~2-3min
First control-plane, worker-nodes are created after ~4min
Cluster creation without packer and snapshot 3 control planes, 3 worker ~10min
Worker upscale ~1-2min
Worker downscale ~20s
Control plane upscale per node ~2.5min
Control plane downscale per node ~1min

Quick start

More information available in the Cluster API - Quick Start guide

Before you can start you need a management Cluster. If you have no management cluster you can use the ./demo/setup.sh to get a kind cluster. If you are not using the script because you have already a managment cluster please ensure to have the following enabled:

export EXP_CLUSTER_RESOURCE_SET=true
clusterctl init --core cluster-api:v0.3.13

Please ensure you have a recent clusterctl release (tested with v0.3.16). You can test with clusterctl version

Now we can start by creating a secret in management cluster. $TOKEN is a placeholder for your HETZNER API Token. You can create one in your Project under security/API TOKENS.

kubectl create secret generic hetzner-token --from-literal=token=$TOKEN

Then we need to create an SSH Key for the nodes. Because this is a quickstart we have specified the name of the Key, but of course feel free to change the name, but remember to do it also in cluster.yaml file. Then upload the public Key to Hetzner Cloud.

ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/cluster

For deploying necessary applications like the CNI, CCM, CSI etc. We use the ClusterResourceSets and apply them to our managment cluster.

kubectl apply -f ./demo/ClusterResourceSets

Then we need to register this infrastructure provider in your $HOME/.cluster-api/clusterctl.yaml:

providers:
  - name: "hcloud"
    url: "https://github.com/cluster-api-provider-hcloud/cluster-api-provider-hcloud/releases/latest/infrastructure-components.yaml"
    type: "InfrastructureProvider"

Now we deploy the API components to the management cluster

clusterctl init --infrastructure hcloud:v0.1.4

Now we can deploy our first Cluster. For production use it is recommended to use your own templates with all configurations. [name] is the placeholder for your cluster name like cluster-dev

clusterctl config cluster [name] | kubectl apply -f -

or use helm

helm install cluster ./demo/helm-charts/cluster-demo

You can check now the status of your target cluster via your management cluster:

kubectl get cluster --all-namespaces

### To verify the first control plane is up:
kubectl get kubeadmcontrolplane --all-namespaces

To get access to your target cluster you can retrieve the kubeconfig file and use it via ENV. [name] is the placeholder for your above defined cluster name.

export KUBECONFIG_GUEST=$(pwd)/.kubeconfig-[name]
kubectl --namespace=default get secret [name]-kubeconfig \
   -o jsonpath={.data.value} | base64 --decode \
   > $KUBECONFIG_GUEST

To verify you have access try:

KUBECONFIG=$KUBECONFIG_GUEST kubectl get nodes

If you want you can now move all the cluster-api Resources from your management Cluster to your Target Cluster:

export EXP_CLUSTER_RESOURCE_SET=true
KUBECONFIG=$KUBECONFIG_GUEST clusterctl init --core cluster-api:v0.3.16
KUBECONFIG=$KUBECONFIG_GUEST clusterctl init --infrastructure hcloud:v0.1.4
clusterctl move --to-kubeconfig $KUBECONFIG_GUEST

### You also need to create your Hetzner Token secret on the new management cluster
### If you use helm please keep in mind to also move the helm secret 

To delete the cluster (if management cluster not equal target cluster)

kubectl delete cluster [name]

or with helm

helm uninstall cluster

To delete your managment cluster (setup via setup.sh)

kind delete cluster --name capi-hcloud

Debugging

### Getting information about the cluster
KUBECONFIG=$KUBECONFIG_GUEST kubectl get all,nodes -A

### Getting informations about cluster-api
watch kubectl get hcloudclusters,cluster,hcloudmachines,baremetalmachines,machines

### cluster-info
KUBECONFIG=$KUBECONFIG_GUEST kubectl get cm cluster-info -n kube-public -o yaml

# Logs
### Provider Integration
kubectl logs -f deployment/capi-hcloud-controller-manager -c manager -n capi-hcloud-system

### Cluster-API Controller
kubectl logs -f deployment/capi-controller-manager -c manager -n capi-system

### Bootstrap Controller
kubectl logs -f deployment/capi-kubeadm-bootstrap-controller-manager -c manager  -n capi-kubeadm-bootstrap-system

### Kubeadm Control-plane Controller
kubectl logs -f deployment/capi-kubeadm-control-plane-controller-manager -c manager  -n capi-kubeadm-control-plane-system

### Kubernetes Events
kubectl get events -o custom-columns=FirstSeen:.firstTimestamp,LastSeen:.lastTimestamp,Count:.count,From:.source.component,Type:.type,Reβ”‚
ason:.reason,Message:.message --watch

### Get kubeadm-config
kubectl -n kube-system get cm kubeadm-config -o yaml

For Developers

Please use this for testing!

See ./docs/src/developers or https://docs.capihc.com/developer/developer.html

Prerequisites

  • clusterctl

  • docker

  • kind

  • kubectl

  • kustomize

  • kubebuilder

  • packer

  • BAZEL

  • Go 1.13

  • gomock

  • watch (On MAC: brew install watch)

  • JQ (On MAC: brew install jq)

  • Running development version

This creates the management cluster with all the controllers

# Deploy kind cluster with cluster-api core componets
./demo/setup.sh

# Build project and deploy to local cluster
make deploy_kind
  • Applying the target cluster with demo-cluster
# Please create an SSH Key for later access on the nodes.
ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/cluster

# Create a Project on Hetzner Cloud and upload the public key. 

# Create a token on Hetzner Cloud and apply it as secret
kubectl create secret generic hetzner-token --from-literal=token=$TOKEN

#For automatic installation of manifests we use ClusterResourceSets
kubectl apply -f demo/ClusterResourceSets

## You can choose which manifests should be applyed by setting the value of the labels under kind: Cluster

# Apply the manifest to your management cluster; use quickstart guide for getting access to the target cluster
kubectl apply -f ./demo/cluster-minimal.yaml

## Get Logs:
kubectl logs -f deployment/capi-hcloud-controller-manager -c manager --v=4 -n capi-hcloud-system

# Deleting the target cluster
kubectl delete -f ./demo/demo-cluster.yaml

# Deleting the controller
make delete_capihc

# Deleting the management cluster
kind delete cluster --name capi-hcloud

cluster-api-provider-hcloud's Projects

hrobot-go icon hrobot-go

A Go library for the Hetzner Robot API https://robot.your-server.de/doc/webservice/en.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.