Skip to content

Commit

Permalink
chore(hetzner): setup kubernetes-dev-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
apricote committed Oct 28, 2024
1 parent 6a02299 commit 2953386
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cluster-autoscaler/cloudprovider/hetzner/dev/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.terraform/
terraform.tfstate*
*.auto.tfvars

files/
114 changes: 114 additions & 0 deletions cluster-autoscaler/cloudprovider/hetzner/dev/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions cluster-autoscaler/cloudprovider/hetzner/dev/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
SHELL = bash

ENV ?= dev
K3S_CHANNEL ?= stable

env.auto.tfvars:
@echo 'name = "$(ENV)"' > "$@"
@echo 'hcloud_token = "$(HCLOUD_TOKEN)"' >> "$@"
@echo 'k3s_channel = "$(K3S_CHANNEL)"' >> "$@"

.terraform:
tofu init

validate: .terraform
tofu validate

up: .terraform env.auto.tfvars
tofu apply -auto-approve
$(MAKE) port-forward

down: .terraform env.auto.tfvars
files/registry-port-forward.sh down
tofu destroy -auto-approve

port-forward:
source files/env.sh && files/registry-port-forward.sh up

clean:
rm -Rf files/ .terraform/ terraform.tfstate* env.auto.tfvars
8 changes: 8 additions & 0 deletions cluster-autoscaler/cloudprovider/hetzner/dev/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module "dev" {
source = "github.com/hetznercloud/kubernetes-dev-env?ref=v0.6.0" # x-release-please-version

name = "cas-${replace(var.name, "/[^a-zA-Z0-9-_]/", "-")}"
hcloud_token = var.hcloud_token

k3s_channel = var.k3s_channel
}
10 changes: 10 additions & 0 deletions cluster-autoscaler/cloudprovider/hetzner/dev/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
variable "name" {
type = string
}
variable "hcloud_token" {
type = string
sensitive = true
}
variable "k3s_channel" {
type = string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
export K3S_URL=https://YOUR_IP:6443
# From /var/lib/rancher/k3s/server/token
export K3S_TOKEN=YOUR_TOKEN
export INSTALL_K3S_CHANNEL=v1.31
EXTERNAL_IP=$(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
INTERNAL_IP=$(ip -4 addr show enp7s0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
curl -sfL https://get.k3s.io | sh -s - --kubelet-arg=cloud-provider=external --node-external-ip $EXTERNAL_IP --node-ip $INTERNAL_IP
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: kube-system

resources:
- cluster-autoscaler-run-on-master.yaml

secretGenerator:
- name: cluster-autoscaler-cloud-init
files:
- cloudinit=cloud-init.sh.b64
20 changes: 20 additions & 0 deletions cluster-autoscaler/cloudprovider/hetzner/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: skaffold/v4beta3
kind: Config
metadata:
name: cluster-autoscaler-hetzner
build:
artifacts:
- image: registry.k8s.io/autoscaling/cluster-autoscaler
context: ../../
ko:
flags:
- -tags=hetzner

local:
useBuildkit: true
insecureRegistries:
- localhost:30666
manifests:
kustomize:
paths:
- examples/

0 comments on commit 2953386

Please sign in to comment.