Skip to content

Commit

Permalink
refactor chart
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Paskal <[email protected]>
  • Loading branch information
maksim-paskal committed Nov 6, 2023
1 parent 9e44f4c commit 150d9c8
Show file tree
Hide file tree
Showing 42 changed files with 1,274 additions and 1,439 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on:
pull_request:

jobs:
e2e:
name: e2e
runs-on: self-hosted
steps:
- uses: actions/setup-go@v2
with:
go-version: '1.21'
- uses: actions/checkout@v2
- run: make e2e
env:
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
KUBECONFIG=$(HOME)/.kube/hcloud
action=list-configurations
config=config.yaml
fullConfig=./examples/config-full.yaml
fullConfig=./e2e/configs/full.yaml
args=""

test:
Expand All @@ -10,6 +10,9 @@ test:
go mod tidy
go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run -v
CONFIG=config_test.yaml go test -race -coverprofile coverage.out ./cmd/... ./pkg/...
.PHONY: e2e
e2e:
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` go test -v -count=1 -timeout=4h ./e2e/e2e_test.go
coverage:
go tool cover -html=coverage.out
create-cluster:
Expand Down Expand Up @@ -49,9 +52,6 @@ test-kubernetes-yaml:
helm lint ./examples/charts/test --values=$(fullConfig)
helm template ./scripts/chart --values=$(fullConfig) | kubectl apply --dry-run=client --validate=true -f -
helm template ./examples/charts/test --values=$(fullConfig) | kubectl apply --dry-run=client --validate=true -f -
download-yamls:
curl -sSL -o ./scripts/chart/templates/kube-flannel.yml https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
curl -sSL -o ./scripts/chart/templates/metrics-server.yml https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
install:
go run github.com/goreleaser/goreleaser@latest build \
--single-target \
Expand Down
22 changes: 8 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ for other OS download binnary from [release pages](https://github.com/maksim-pas

This will create kubernetes cluster in Hetzner Cloud Europe region with 3 instances, 1 load balancer for the kubernetes control plane and 1 kubernetes worker node, after successful installation the cluster will have:

- [Kubernetes v1.24](https://github.com/kubernetes/kubernetes)
- [Kubernetes v1.26](https://github.com/kubernetes/kubernetes)
- [Kubernetes Autoscaler](https://github.com/kubernetes/autoscaler)
- [Flannel](https://github.com/flannel-io/flannel)
- [Kubernetes Cloud Controller Manager for Hetzner Cloud](https://github.com/hetznercloud/hcloud-cloud-controller-manager)
Expand All @@ -36,7 +36,7 @@ This will create kubernetes cluster in Hetzner Cloud Europe region with 3 instan

for HA needs odd number of master nodes (minimum 3) <https://etcd.io/docs/v3.4/faq/#why-an-odd-number-of-cluster-members>

create a simple configuration file `config.yaml` full configuration example [here](https://github.com/maksim-paskal/hcloud-k8s-ctl/blob/main/examples/config-full.yaml)
Create a simple configuration file `config.yaml` full configuration example [here](https://github.com/maksim-paskal/hcloud-k8s-ctl/blob/main/e2e/configs/full.yaml)

```yaml
# kubeconfig path
Expand All @@ -49,22 +49,16 @@ ipRange: "10.0.0.0/16"
masterCount: 3
```
to create kubernetes cluster in Hetzner Cloud US region append to `config.yaml` next lines
More examples of configuration files:
<details>
<summary>Create cluster in Hetzner Cloud US region</summary>
```yaml
networkZone: us-east
location: ash
datacenter: ash-dc1
masterServers:
servertype: cpx21
autoscaler:
workers:
- location: ash
type:
- cpx51
# e2e/configs/us-cluster.yaml
```

and start application
</details>

```bash
# create 3 instance with 1 load balancer
Expand Down
6 changes: 3 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"syscall"
"time"

"github.com/maksim-paskal/hcloud-k8s-ctl/internal"
"github.com/maksim-paskal/hcloud-k8s-ctl/pkg/api"
"github.com/maksim-paskal/hcloud-k8s-ctl/pkg/config"
log "github.com/sirupsen/logrus"
Expand All @@ -47,7 +48,7 @@ func main() { //nolint:cyclop,funlen

log.SetReportCaller(true)

if err := config.Load(); err != nil {
if err := internal.Init(); err != nil {
log.WithError(err).Fatal("error loading config")
}

Expand All @@ -58,8 +59,6 @@ func main() { //nolint:cyclop,funlen

log.SetLevel(logLevel)

log.Infof("Loaded config:\n%s\n", config.String())

if err := config.Check(); err != nil {
log.WithError(err).Fatal("error checking config")
}
Expand Down Expand Up @@ -123,6 +122,7 @@ func getInterruptionContext() context.Context {

go func() {
<-c
log.Warn("Received interruption signal, stopping...")
cancel()

// wait 5s for graceful shutdown
Expand Down
124 changes: 124 additions & 0 deletions e2e/configs/full.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
clusterName: k8s
serverComponents:
ubuntu:
version: ubuntu-20.04
username: hcloud-user
architecture: x86
kubernetes:
version: 1.26.9
docker:
version: 5:24.0.6-1~ubuntu.20.04~focal
containerd:
version: 1.6.24-1
pausecontainer: registry.k8s.io/pause:3.2
ipRange: 10.0.0.0/16
ipRangeSubnet: 10.0.0.0/16
masterCount: 3
networkZone: eu-central
location: fsn1
datacenter: fsn1-dc14
masterServers:
namepattern: master-%d
placementgroupname: master-placement-group
servertype: cx21
labels:
role: master
waittimeinretry: 3s
retrytimelimit: 20
serversinitparams:
targz: https://github.com/maksim-paskal/hcloud-k8s-ctl/archive/refs/heads/main.tar.gz
folder: hcloud-k8s-ctl-main
masterLoadBalancer:
loadbalancertype: lb11
listenport: 6443
destinationport: 6443
cliArgs:
loglevel: DEBUG
configpath: config.yaml
saveconfigpath: ./e2e/configs/full.yaml
action: save-full-config
adhoccommand: ""
adhoccopynewfile: false
adhocmasters: false
adhocworkers: true
adhocuser: ""
upgradecontrolplaneversion: ""
createfirewallcontrolplane: false
createfirewallworkers: false
deployments: {}
preStartScript: ""
postStartScript: ""
cluster-autoscaler:
autoscalingGroups:
- name: CX21:FSN1:cx21-fsn1
minSize: 1
maxSize: 20
- name: CPX21:FSN1:cpx21-fsn1
minSize: 1
maxSize: 20
- name: CX31:FSN1:cx31-fsn1
minSize: 1
maxSize: 20
- name: CPX31:FSN1:cpx31-fsn1
minSize: 1
maxSize: 20
- name: CX41:FSN1:cx41-fsn1
minSize: 1
maxSize: 20
- name: CPX41:FSN1:cpx41-fsn1
minSize: 1
maxSize: 20
- name: CX51:FSN1:cx51-fsn1
minSize: 1
maxSize: 20
- name: CPX51:FSN1:cpx51-fsn1
minSize: 1
maxSize: 20
- name: CX21:NBG1:cx21-nbg1
minSize: 1
maxSize: 20
- name: CPX21:NBG1:cpx21-nbg1
minSize: 1
maxSize: 20
- name: CX31:NBG1:cx31-nbg1
minSize: 1
maxSize: 20
- name: CPX31:NBG1:cpx31-nbg1
minSize: 1
maxSize: 20
- name: CX41:NBG1:cx41-nbg1
minSize: 1
maxSize: 20
- name: CPX41:NBG1:cpx41-nbg1
minSize: 1
maxSize: 20
- name: CX51:NBG1:cx51-nbg1
minSize: 1
maxSize: 20
- name: CPX51:NBG1:cpx51-nbg1
minSize: 1
maxSize: 20
- name: CX21:HEL1:cx21-hel1
minSize: 1
maxSize: 20
- name: CPX21:HEL1:cpx21-hel1
minSize: 1
maxSize: 20
- name: CX31:HEL1:cx31-hel1
minSize: 1
maxSize: 20
- name: CPX31:HEL1:cpx31-hel1
minSize: 1
maxSize: 20
- name: CX41:HEL1:cx41-hel1
minSize: 1
maxSize: 20
- name: CPX41:HEL1:cpx41-hel1
minSize: 1
maxSize: 20
- name: CX51:HEL1:cx51-hel1
minSize: 1
maxSize: 20
- name: CPX51:HEL1:cpx51-hel1
minSize: 1
maxSize: 20
9 changes: 9 additions & 0 deletions e2e/configs/v1.25.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ipRange: "10.0.0.0/16"
masterCount: 3
serverComponents:
kubernetes:
version: 1.25.14
docker:
version: 5:24.0.6-1~ubuntu.20.04~focal
containerd:
version: 1.6.24-1
19 changes: 19 additions & 0 deletions e2e/configs/v1.26-amd64-us-east.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ipRange: "10.0.0.0/16"
masterCount: 3
networkZone: us-east
location: ash
datacenter: ash-dc1
masterServers:
servertype: cpx21
serverComponents:
kubernetes:
version: 1.26.9
docker:
version: 5:24.0.6-1~ubuntu.20.04~focal
containerd:
version: 1.6.24-1
cluster-autoscaler:
autoscalingGroups:
- name: CPX51:ASH:cpx51-ash
minSize: 1
maxSize: 20
9 changes: 9 additions & 0 deletions e2e/configs/v1.26-amd64.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ipRange: "10.0.0.0/16"
masterCount: 3
serverComponents:
kubernetes:
version: 1.26.9
docker:
version: 5:24.0.6-1~ubuntu.20.04~focal
containerd:
version: 1.6.24-1
18 changes: 18 additions & 0 deletions e2e/configs/v1.26-arm64.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ipRange: "10.0.0.0/16"
masterCount: 3
serverComponents:
ubuntu:
architecture: arm
kubernetes:
version: 1.26.9
docker:
version: 5:24.0.6-1~ubuntu.20.04~focal
containerd:
version: 1.6.24-1
masterServers:
servertype: cax11
cluster-autoscaler:
autoscalingGroups:
- name: CAX41:FSN1:cax-fsn1
minSize: 1
maxSize: 20
9 changes: 9 additions & 0 deletions e2e/configs/v1.27.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ipRange: "10.0.0.0/16"
masterCount: 3
serverComponents:
kubernetes:
version: 1.27.6
docker:
version: 5:24.0.6-1~ubuntu.20.04~focal
containerd:
version: 1.6.24-1
9 changes: 9 additions & 0 deletions e2e/configs/v1.28.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ipRange: "10.0.0.0/16"
masterCount: 3
serverComponents:
kubernetes:
version: 1.28.2
docker:
version: 5:24.0.6-1~ubuntu.20.04~focal
containerd:
version: 1.6.24-1
Loading

0 comments on commit 150d9c8

Please sign in to comment.