-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lukas Kämmerling <[email protected]>
- Loading branch information
1 parent
4ba14b9
commit dd83234
Showing
5 changed files
with
268 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
cluster-autoscaler/cloudprovider/hetzner/examples/cloud-init.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
export DEBIAN_FRONTEND=noninteractive | ||
export HOME=/root/ | ||
apt-get update && apt-get install -y apt-transport-https ca-certificates curl software-properties-common | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - | ||
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - | ||
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list | ||
deb https://apt.kubernetes.io/ kubernetes-xenial main | ||
EOF | ||
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | ||
apt-get update | ||
apt-get upgrade -y | ||
apt-get install -y kubelet=1.20.1-00 kubeadm=1.20.1-00 kubectl=1.20.1-00 | ||
apt-mark hold kubelet kubeadm kubectl | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - | ||
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" | ||
apt update | ||
apt install -y docker-ce | ||
cat <<EOF | tee /etc/default/kubelet | ||
KUBELET_EXTRA_ARGS=--cloud-provider=external | ||
EOF | ||
cat > /etc/docker/daemon.json <<EOF | ||
{ | ||
"exec-opts": ["native.cgroupdriver=systemd"], | ||
"log-driver": "json-file", | ||
"log-opts": { | ||
"max-size": "100m" | ||
}, | ||
"storage-driver": "overlay2" | ||
} | ||
EOF | ||
mkdir -p /etc/systemd/system/docker.service.d | ||
systemctl daemon-reload | ||
systemctl restart docker | ||
kubeadm join <master-ip> --token <token> --discovery-token-ca-cert-hash sha256:<hash> |
190 changes: 190 additions & 0 deletions
190
cluster-autoscaler/cloudprovider/hetzner/examples/cluster-autoscaler-run-on-master.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
labels: | ||
k8s-addon: cluster-autoscaler.addons.k8s.io | ||
k8s-app: cluster-autoscaler | ||
name: cluster-autoscaler | ||
namespace: kube-system | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: cluster-autoscaler | ||
labels: | ||
k8s-addon: cluster-autoscaler.addons.k8s.io | ||
k8s-app: cluster-autoscaler | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["events", "endpoints"] | ||
verbs: ["create", "patch"] | ||
- apiGroups: [""] | ||
resources: ["pods/eviction"] | ||
verbs: ["create"] | ||
- apiGroups: [""] | ||
resources: ["pods/status"] | ||
verbs: ["update"] | ||
- apiGroups: [""] | ||
resources: ["endpoints"] | ||
resourceNames: ["cluster-autoscaler"] | ||
verbs: ["get", "update"] | ||
- apiGroups: [""] | ||
resources: ["nodes"] | ||
verbs: ["watch", "list", "get", "update"] | ||
- apiGroups: [""] | ||
resources: | ||
- "pods" | ||
- "services" | ||
- "replicationcontrollers" | ||
- "persistentvolumeclaims" | ||
- "persistentvolumes" | ||
verbs: ["watch", "list", "get"] | ||
- apiGroups: ["extensions"] | ||
resources: ["replicasets", "daemonsets"] | ||
verbs: ["watch", "list", "get"] | ||
- apiGroups: ["policy"] | ||
resources: ["poddisruptionbudgets"] | ||
verbs: ["watch", "list"] | ||
- apiGroups: ["apps"] | ||
resources: ["statefulsets", "replicasets", "daemonsets"] | ||
verbs: ["watch", "list", "get"] | ||
- apiGroups: ["storage.k8s.io"] | ||
resources: ["storageclasses", "csinodes"] | ||
verbs: ["watch", "list", "get"] | ||
- apiGroups: ["batch", "extensions"] | ||
resources: ["jobs"] | ||
verbs: ["get", "list", "watch", "patch"] | ||
- apiGroups: ["coordination.k8s.io"] | ||
resources: ["leases"] | ||
verbs: ["create"] | ||
- apiGroups: ["coordination.k8s.io"] | ||
resourceNames: ["cluster-autoscaler"] | ||
resources: ["leases"] | ||
verbs: ["get", "update"] | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: cluster-autoscaler | ||
namespace: kube-system | ||
labels: | ||
k8s-addon: cluster-autoscaler.addons.k8s.io | ||
k8s-app: cluster-autoscaler | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["configmaps"] | ||
verbs: ["create","list","watch"] | ||
- apiGroups: [""] | ||
resources: ["configmaps"] | ||
resourceNames: ["cluster-autoscaler-status", "cluster-autoscaler-priority-expander"] | ||
verbs: ["delete", "get", "update", "watch"] | ||
|
||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: cluster-autoscaler | ||
labels: | ||
k8s-addon: cluster-autoscaler.addons.k8s.io | ||
k8s-app: cluster-autoscaler | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: cluster-autoscaler | ||
subjects: | ||
- kind: ServiceAccount | ||
name: cluster-autoscaler | ||
namespace: kube-system | ||
|
||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: cluster-autoscaler | ||
namespace: kube-system | ||
labels: | ||
k8s-addon: cluster-autoscaler.addons.k8s.io | ||
k8s-app: cluster-autoscaler | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: cluster-autoscaler | ||
subjects: | ||
- kind: ServiceAccount | ||
name: cluster-autoscaler | ||
namespace: kube-system | ||
|
||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: cluster-autoscaler | ||
namespace: kube-system | ||
labels: | ||
app: cluster-autoscaler | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: cluster-autoscaler | ||
template: | ||
metadata: | ||
labels: | ||
app: cluster-autoscaler | ||
annotations: | ||
prometheus.io/scrape: 'true' | ||
prometheus.io/port: '8085' | ||
spec: | ||
serviceAccountName: cluster-autoscaler | ||
tolerations: | ||
- effect: NoSchedule | ||
key: node-role.kubernetes.io/master | ||
# Node affinity is used to force cluster-autoscaler to stick | ||
# to the master node. This allows the cluster to reliably downscale | ||
# to zero worker nodes when needed. | ||
affinity: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: node-role.kubernetes.io/master | ||
operator: Exists | ||
containers: | ||
- image: k8s.gcr.io/autoscaling/cluster-autoscaler:latest # or your custom image | ||
name: cluster-autoscaler | ||
resources: | ||
limits: | ||
cpu: 100m | ||
memory: 300Mi | ||
requests: | ||
cpu: 100m | ||
memory: 300Mi | ||
command: | ||
- ./cluster-autoscaler | ||
- --cloud-provider=hetzner | ||
- --stderrthreshold=info | ||
- --nodes=1:10:CPX11:FSN1:pool1 | ||
env: | ||
- name: HCLOUD_TOKEN | ||
valueFrom: | ||
secretKeyRef: | ||
name: hcloud | ||
key: token | ||
- name: HCLOUD_CLOUD_INIT | ||
value: <your-cloud-init-data-base64-encoded> | ||
# - name: HCLOUD_SSH_KEY | ||
# value: <optional SSH Key Name or ID> | ||
# - name: HCLOUD_NETWORK | ||
# value: <optional Network Name or ID> | ||
volumeMounts: | ||
- name: ssl-certs | ||
mountPath: /etc/ssl/certs/ca-certificates.crt | ||
readOnly: true | ||
imagePullPolicy: "Always" | ||
imagePullSecrets: | ||
- name: gitlab-registry | ||
volumes: | ||
- name: ssl-certs | ||
hostPath: | ||
path: "/etc/ssl/certs/ca-certificates.crt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters