-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of K3s manager (#189)
* Unify Kubespray templates and remove unnecessary subpackage Signed-off-by: Din Music <din.music@din-cloud.com> * Makefile: Add makefile with build and test commands Signed-off-by: Din Music <din.music@din-cloud.com> * pkg/utils/exec: Add remote and local exec Signed-off-by: Din Music <din.music@din-cloud.com> * embed: Add K3s templates and remove unnecessary host checks Signed-off-by: Din Music <din.music@din-cloud.com> * pkg/tools/git: Add support for commit checkout Signed-off-by: Din Music <din.music@din-cloud.com> * pkg/tools/ansible: Accept env vars as map instead of array Signed-off-by: Din Music <din.music@din-cloud.com> * pkg: Add k3s manager Signed-off-by: Din Music <din.music@din-cloud.com> * pkg: Rename executor to manager Signed-off-by: Din Music <din.music@din-cloud.com> * pkg/tools/virtualenv: Simplify invocation by removing working dir argument Signed-off-by: Din Music <din.music@din-cloud.com> * pkg/cluster: Manager wrapper with common logic Signed-off-by: Din Music <din.music@din-cloud.com> * embed/templates/k3s: Add support for node labels and taints, and external load balancer Signed-off-by: Din Music <din.music@din-cloud.com> * docs: Add k3s manager in configurtion section Signed-off-by: Din Music <din.music@din-cloud.com> * pkg/models/config: Always set load balancer default value Signed-off-by: Din Music <din.music@din-cloud.com> * pkg: Remove debug outputs Signed-off-by: Din Music <din.music@din-cloud.com> * embed/ansible: Fetch final k3s config Signed-off-by: Din Music <din.music@din-cloud.com> --------- Signed-off-by: Din Music <din.music@din-cloud.com>
- Loading branch information
Showing
50 changed files
with
1,545 additions
and
967 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
build: | ||
go build -ldflags "-s -w" -trimpath -o kubitect ./cmd | ||
|
||
test: | ||
go test ./... -v |
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 was deleted.
Oops, something went wrong.
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,4 +1,3 @@ | ||
ansible==8.5.0 | ||
ansible-core==2.16.2 | ||
jinja2==3.1.2 | ||
netaddr==0.9.0 |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,70 @@ | ||
{{- $cfgNodes := .Values.ConfigNodes -}} | ||
{{- $infNodes := .Values.InfraNodes -}} | ||
--- | ||
all: | ||
hosts: | ||
{{- range $infNodes.LoadBalancer.Instances }} | ||
{{- $i := $cfgNodes.LoadBalancer.Instances | select "Id" .Id | first }} | ||
{{ .Name }}: | ||
ansible_host: {{ .IP }} | ||
priority: {{ $i.Priority }} | ||
{{- end }} | ||
{{- range $infNodes.Master.Instances }} | ||
{{- $i := $cfgNodes.Master.Instances | select "Id" .Id | first }} | ||
{{ .Name }}: | ||
ansible_host: {{ .IP }} | ||
server_config_yaml: |- | ||
--- | ||
tls-san: {{ $infNodes.LoadBalancer.VIP }} | ||
{{- if $i.Labels }} | ||
node-label: | ||
{{- range $k, $v := $i.Labels }} | ||
- "{{ $k }}={{ $v }}" | ||
{{- end }} | ||
{{- end }} | ||
{{- if $i.Taints }} | ||
node-taint: | ||
{{- range $i.Taints }} | ||
- "{{ . }}" | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
{{- range $infNodes.Worker.Instances }} | ||
{{- $i := $cfgNodes.Worker.Instances | select "Id" .Id | first }} | ||
{{ .Name }}: | ||
ansible_host: {{ .IP }} | ||
server_config_yaml: |- | ||
--- | ||
{{- if $i.Labels }} | ||
node-label: | ||
{{- range $k, $v := $i.Labels }} | ||
- "{{ $k }}={{ $v }}" | ||
{{- end }} | ||
{{- end }} | ||
{{- if $i.Taints }} | ||
node-taint: | ||
{{- range $i.Taints }} | ||
- "{{ . }}" | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
children: | ||
haproxy: | ||
hosts: | ||
{{- range $infNodes.LoadBalancer.Instances }} | ||
{{ .Name }}: | ||
{{- end }} | ||
k3s_cluster: | ||
children: | ||
server: | ||
hosts: | ||
{{- range $infNodes.Master.Instances }} | ||
{{ .Name }}: | ||
{{- end }} | ||
agent: | ||
hosts: | ||
{{- if $infNodes.Worker.Instances }} | ||
{{- range $infNodes.Worker.Instances }} | ||
{{ .Name }}: | ||
{{- end }} | ||
{{- end }} |
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,20 @@ | ||
{{- $nodes := .Values -}} | ||
--- | ||
k3s_cluster: | ||
children: | ||
server: | ||
hosts: | ||
{{ range $name, $node := $nodes }} | ||
{{- if eq $node.GetTypeName "master" }} | ||
{{ $name }}: | ||
ansible_host: {{ $node.IP }} | ||
{{- end }} | ||
{{- end }} | ||
agent: | ||
hosts: | ||
{{ range $name, $node := $nodes }} | ||
{{- if eq $node.GetTypeName "worker" }} | ||
{{ $name }}: | ||
ansible_host: {{ $node.IP }} | ||
{{- end }} | ||
{{- end }} |
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
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,12 @@ | ||
## | ||
# Kubesprays's source file (v2.17.1): | ||
# https://github.com/kubernetes-sigs/kubespray/blob/v2.17.1/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml | ||
## | ||
--- | ||
auto_renew_certificates: {{ .Values.Kubernetes.Other.AutoRenewCertificates }} | ||
cluster_name: cluster.local | ||
dns_mode: {{ .Values.Kubernetes.DnsMode }} | ||
kube_version: {{ .Values.Kubernetes.Version }} | ||
kube_network_plugin: {{ .Values.Kubernetes.NetworkPlugin }} | ||
kube_proxy_strict_arp: true | ||
resolvconf_mode: host_resolvconf |
Oops, something went wrong.