-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request 'Increasing worker node count to 2 in the generate…
…d AWS sample config file | Added support for MachinePool labels and taints' (#12) from increase-root-ebs-volume-size into main Reviewed-on: https://gitea.obmondo.com/EnableIT/kubeaid-bootstrap-script/pulls/12
- Loading branch information
Showing
11 changed files
with
311 additions
and
109 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
[Makefile] | ||
indent_style = tab | ||
tab_width = 2 | ||
|
||
[*.yaml, *.yaml.tmpl] | ||
indent_style = space | ||
indent_size = 2 |
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
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
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,77 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"log/slog" | ||
"os" | ||
"strings" | ||
|
||
"github.com/go-playground/validator/v10" | ||
"github.com/siderolabs/talos/pkg/machinery/labels" | ||
) | ||
|
||
var ( | ||
// A user defined MachinePool label key should belong to one of these domains. | ||
// REFER : https://cluster-api.sigs.k8s.io/developer/architecture/controllers/metadata-propagation#machine. | ||
ValidMachinePoolLabelDomains = []string{ | ||
"node.cluster.x-k8s.io/", | ||
"node-role.kubernetes.io/", | ||
"node-restriction.kubernetes.io/", | ||
} | ||
) | ||
|
||
// Validates the parsed config. | ||
// Panics on failure. | ||
// TODO : Extract the MachinePool labels and taints validation task from 'cloud specifics' section. | ||
func validateConfig(config *Config) { | ||
// Validate based on struct tags. | ||
validate := validator.New(validator.WithRequiredStructEnabled()) | ||
if err := validate.Struct(config); err != nil { | ||
log.Fatalf("config validation failed : %v", err) | ||
} | ||
|
||
// Cloud provider specific validations. | ||
switch { | ||
case config.Cloud.AWS != nil: | ||
|
||
for _, machinePool := range config.Cloud.AWS.MachinePools { | ||
// Validate MachinePools labels. | ||
// | ||
// (1) according to Kubernetes specifications. | ||
if err := labels.Validate(machinePool.Labels); err != nil { | ||
log.Fatalf("MachinePool labels validation failed : %v", err) | ||
} | ||
// | ||
// (2) according to ClusterAPI specifications. | ||
for key := range machinePool.Labels { | ||
// Check if the label belongs to a domain considered valid by ClusterAPI. | ||
isValidMachinePoolLabelDomain := false | ||
for _, machinePoolLabelDomains := range ValidMachinePoolLabelDomains { | ||
if strings.HasPrefix(key, machinePoolLabelDomains) { | ||
isValidMachinePoolLabelDomain = true | ||
break | ||
} | ||
} | ||
if !isValidMachinePoolLabelDomain { | ||
slog.Error("MachinePool label key should belong to one of these domains", slog.Any("domains", ValidMachinePoolLabelDomains)) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
taintsAsKVPairs := map[string]string{} | ||
for _, taint := range machinePool.Taints { | ||
taintsAsKVPairs[taint.Key] = fmt.Sprintf("%s:%s", taint.Value, taint.Effect) | ||
} | ||
// | ||
// Validate MachinePool taints. | ||
if err := labels.ValidateTaints(taintsAsKVPairs); err != nil { | ||
log.Fatalf("MachinePool taint validation failed : %v", err) | ||
} | ||
} | ||
|
||
case config.Cloud.Azure != nil: | ||
case config.Cloud.Hetzner != nil: | ||
log.Fatal("Support for Azure and Hetzner are coming soon") | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,73 @@ | ||
module github.com/Obmondo/kubeaid-bootstrap-script | ||
|
||
go 1.22.1 | ||
go 1.22.7 | ||
|
||
require ( | ||
github.com/creasty/defaults v1.8.0 | ||
github.com/go-git/go-git/v5 v5.12.0 | ||
github.com/go-playground/validator/v10 v10.22.1 | ||
github.com/go-sprout/sprout v0.6.0 | ||
github.com/siderolabs/talos/pkg/machinery v1.8.2 | ||
github.com/urfave/cli/v2 v2.27.4 | ||
gopkg.in/yaml.v3 v3.0.1 | ||
k8s.io/api v0.31.2 | ||
) | ||
|
||
require ( | ||
dario.cat/mergo v1.0.0 // indirect | ||
github.com/Masterminds/semver/v3 v3.2.1 // indirect | ||
github.com/Microsoft/go-winio v0.6.1 // indirect | ||
github.com/ProtonMail/go-crypto v1.0.0 // indirect | ||
github.com/cloudflare/circl v1.3.7 // indirect | ||
github.com/ProtonMail/go-crypto v1.1.0-alpha.5.0.20240827111422-b5837fa4476e // indirect | ||
github.com/cloudflare/circl v1.3.9 // indirect | ||
github.com/containerd/go-cni v1.1.10 // indirect | ||
github.com/containernetworking/cni v1.2.3 // indirect | ||
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect | ||
github.com/cyphar/filepath-securejoin v0.2.4 // indirect | ||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | ||
github.com/emirpasic/gods v1.18.1 // indirect | ||
github.com/fxamacker/cbor/v2 v2.7.0 // indirect | ||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect | ||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect | ||
github.com/go-git/go-billy/v5 v5.5.0 // indirect | ||
github.com/go-logr/logr v1.4.2 // indirect | ||
github.com/go-playground/locales v0.14.1 // indirect | ||
github.com/go-playground/universal-translator v0.18.1 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect | ||
github.com/google/gofuzz v1.2.0 // indirect | ||
github.com/google/uuid v1.6.0 // indirect | ||
github.com/hashicorp/errwrap v1.1.0 // indirect | ||
github.com/hashicorp/go-multierror v1.1.1 // indirect | ||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/kevinburke/ssh_config v1.2.0 // indirect | ||
github.com/leodido/go-urn v1.4.0 // indirect | ||
github.com/mitchellh/copystructure v1.2.0 // indirect | ||
github.com/mitchellh/reflectwalk v1.0.2 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/pjbgf/sha1cd v0.3.0 // indirect | ||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect | ||
github.com/rogpeppe/go-internal v1.12.0 // indirect | ||
github.com/russross/blackfriday/v2 v2.1.0 // indirect | ||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect | ||
github.com/siderolabs/crypto v0.5.0 // indirect | ||
github.com/siderolabs/gen v0.5.0 // indirect | ||
github.com/skeema/knownhosts v1.2.2 // indirect | ||
github.com/spf13/cast v1.6.0 // indirect | ||
github.com/x448/float16 v0.8.4 // indirect | ||
github.com/xanzy/ssh-agent v0.3.3 // indirect | ||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect | ||
golang.org/x/crypto v0.24.0 // indirect | ||
golang.org/x/crypto v0.26.0 // indirect | ||
golang.org/x/mod v0.17.0 // indirect | ||
golang.org/x/net v0.26.0 // indirect | ||
golang.org/x/net v0.28.0 // indirect | ||
golang.org/x/sync v0.8.0 // indirect | ||
golang.org/x/sys v0.24.0 // indirect | ||
golang.org/x/text v0.16.0 // indirect | ||
golang.org/x/text v0.17.0 // indirect | ||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect | ||
gopkg.in/inf.v0 v0.9.1 // indirect | ||
gopkg.in/warnings.v0 v0.1.2 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
k8s.io/apimachinery v0.31.2 // indirect | ||
k8s.io/klog/v2 v2.130.1 // indirect | ||
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect | ||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect | ||
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect | ||
) |
Oops, something went wrong.