-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(t8s-cluster): add support for HCP (#962)
- Loading branch information
Showing
32 changed files
with
473 additions
and
222 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,2 @@ | ||
controlPlane: | ||
hosted: true |
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,89 @@ | ||
{{- define "t8s-cluster.etcd-defrag" -}} | ||
{{- $_ := mustMerge . (pick .context "Values" "Release" "Chart") -}} | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: kube-etcd-defrag | ||
namespace: {{ .hosted | ternary .Release.Namespace "kube-system" }} | ||
labels: {{- include "common.labels.standard" . | nindent 4 }} | ||
spec: | ||
concurrencyPolicy: Forbid | ||
failedJobsHistoryLimit: 10 | ||
successfulJobsHistoryLimit: 1 | ||
schedule: '42 * * * *' | ||
jobTemplate: | ||
spec: | ||
backoffLimit: 6 | ||
template: | ||
spec: | ||
automountServiceAccountToken: false | ||
containers: | ||
- command: | ||
- etcdctl | ||
- defrag | ||
- --cluster | ||
- --cacert=/etc/kubernetes/pki/etcd/ca.crt | ||
- --cert=/etc/kubernetes/pki/etcd/peer.crt | ||
- --key=/etc/kubernetes/pki/etcd/peer.key | ||
env: | ||
- name: ETCDCTL_API | ||
value: "3" | ||
- name: ETCDCTL_ENDPOINTS | ||
value: {{ .hosted | ternary (printf "kmc-%s-etcd:2379" .Release.Name) "localhost:2379" }} | ||
image: {{ include "common.images.image" (dict "imageRoot" .Values.global.etcd.image "global" .Values.global) }} | ||
imagePullPolicy: IfNotPresent | ||
name: etcd-defrag | ||
securityContext: | ||
runAsGroup: 1000 | ||
runAsUser: {{ .hosted | ternary 1000 0 }} | ||
runAsNonRoot: {{ .hosted }} | ||
privileged: false | ||
allowPrivilegeEscalation: false | ||
seccompProfile: | ||
type: RuntimeDefault | ||
capabilities: | ||
drop: | ||
- ALL | ||
readOnlyRootFilesystem: true | ||
volumeMounts: | ||
- mountPath: /etc/kubernetes/pki/etcd | ||
name: etcd-certs | ||
readOnly: true | ||
dnsPolicy: ClusterFirst | ||
restartPolicy: OnFailure | ||
{{- if not .hosted }} | ||
hostNetwork: true | ||
nodeSelector: | ||
node-role.kubernetes.io/control-plane: "" | ||
tolerations: | ||
- effect: NoSchedule | ||
key: node-role.kubernetes.io/control-plane | ||
operator: Exists | ||
- effect: NoSchedule | ||
key: node-role.kubernetes.io/master | ||
operator: Exists | ||
{{- end }} | ||
volumes: | ||
- name: etcd-certs | ||
{{- if .hosted }} | ||
projected: | ||
defaultMode: 420 | ||
sources: | ||
- secret: | ||
items: | ||
- key: tls.crt | ||
path: ca.crt | ||
name: {{ printf "%s-etcd" .Release.Name }} | ||
- secret: | ||
items: | ||
- key: tls.crt | ||
path: peer.crt | ||
- key: tls.key | ||
path: peer.key | ||
name: {{ printf "%s-etcd-peer" .Release.Name }} | ||
{{- else }} | ||
hostPath: | ||
path: /etc/kubernetes/pki/etcd | ||
type: Directory | ||
{{- 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
12 changes: 12 additions & 0 deletions
12
...tes/management-cluster/clusterClass/bootstrapConfigTemplate/_bootstrapConfigTemplate.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,12 @@ | ||
{{- define "t8s-cluster.clusterClass.bootstrapConfigTemplate" -}} | ||
{{- $_ := mustMerge . (pick .context "Values" "Release" "Chart") -}} | ||
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 | ||
kind: {{ .Values.controlPlane.hosted | ternary "K0sWorkerConfigTemplate" "KubeadmConfigTemplate" }} | ||
metadata: | ||
name: {{ printf "%s-%s-compute-plane" .Release.Name (.gpu | ternary "gpu" "standard") }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: {{- include "common.labels.standard" . | nindent 4 }} | ||
spec: | ||
template: | ||
spec: {{- include (printf "t8s-cluster.clusterClass.bootstrapConfigTemplate.%s.spec" (.Values.controlPlane.hosted | ternary "k0smotron" "kubeadm")) (dict "gpu" .gpu "context" .context) | nindent 6 }} | ||
{{- end -}} |
23 changes: 23 additions & 0 deletions
23
...management-cluster/clusterClass/bootstrapConfigTemplate/_k0smotronConfigTemplateSpec.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,23 @@ | ||
{{- define "t8s-cluster.clusterClass.bootstrapConfigTemplate.k0smotron.spec" -}} | ||
{{- $_ := mustMerge . (pick .context "Values") -}} | ||
{{- $kubeletExtraArgs := list -}} | ||
{{- range $key, $value := include "t8s-cluster.clusterClass.kubeletExtraArgs" (dict "context" .context) | fromYaml -}} | ||
{{- $kubeletExtraArgs = append $kubeletExtraArgs (printf "--%s=%s" $key $value) -}} | ||
{{- end -}} | ||
args: | ||
- --cri-socket=remote:/run/containerd/containerd.sock | ||
{{- if le (.Values.version.minor | int) 28 }} | ||
- --enable-cloud-provider | ||
{{- end }} | ||
- {{ printf `--kubelet-extra-args="%s"` ($kubeletExtraArgs | join " ") }} | ||
files: {{- include "t8s-cluster.clusterClass.configTemplate.files" (dict "context" .context "gpu" .gpu "excludePatches" true) | nindent 2 }} | ||
{{/* this service isn't needed by k0s */}} | ||
{{- $preStartCommands := list | ||
"systemctl disable --now kubelet.service" | ||
}} | ||
{{- $preStartCommands = concat $preStartCommands | ||
(include "t8s-cluster.clusterClass.preKubeadmCommands" (dict "context" .context) | fromYamlArray) | ||
(include "t8s-cluster.clusterClass.postKubeadmCommands" (dict) | fromYamlArray) | ||
}} | ||
preStartCommands: {{- $preStartCommands | default (list) | toYaml | nindent 2 }} | ||
{{- end -}} |
11 changes: 11 additions & 0 deletions
11
...s/management-cluster/clusterClass/bootstrapConfigTemplate/_kubeadmConfigTemplateSpec.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,11 @@ | ||
{{- define "t8s-cluster.clusterClass.bootstrapConfigTemplate.kubeadm.spec" -}} | ||
{{- $_ := mustMerge . (pick .context "Values") -}} | ||
joinConfiguration: | ||
nodeRegistration: | ||
kubeletExtraArgs: {{- include "t8s-cluster.clusterClass.kubeletExtraArgs" (dict "context" .context) | nindent 6 }} | ||
patches: | ||
directory: /etc/kubernetes/patches | ||
files: {{- include "t8s-cluster.clusterClass.configTemplate.files" (dict "context" .context "gpu" .gpu) | nindent 2 }} | ||
preKubeadmCommands: {{- include "t8s-cluster.clusterClass.preKubeadmCommands" (dict "context" .context) | nindent 2 }} | ||
postKubeadmCommands: {{- include "t8s-cluster.clusterClass.postKubeadmCommands" (dict) | nindent 2 }} | ||
{{- end -}} |
1 change: 1 addition & 0 deletions
1
...ment-cluster/clusterClass/bootstrapConfigTemplate/gpuNodePoolBootstrapConfigTemplate.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 @@ | ||
{{- include "t8s-cluster.clusterClass.bootstrapConfigTemplate" (dict "gpu" true "context" $) -}} |
1 change: 1 addition & 0 deletions
1
...cluster/clusterClass/bootstrapConfigTemplate/standardNodePoolBootstrapConfigTemplate.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 @@ | ||
{{- include "t8s-cluster.clusterClass.bootstrapConfigTemplate" (dict "gpu" false "context" $) -}} |
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
7 changes: 7 additions & 0 deletions
7
...ster/templates/management-cluster/clusterClass/k0smotronControlPlaneTemplate/_helpers.tpl
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,7 @@ | ||
{{- define "t8s-cluster.clusterClass.k0smotronControlPlaneTemplate.specHash" -}} | ||
{{/* the full context is needed for .Files.Get */}} | ||
{{- $inputs := (dict | ||
"spec" (include "t8s-cluster.clusterClass.k0smotronControlPlaneTemplate.spec" $) | ||
) -}} | ||
{{- mustToJson $inputs | toString | quote | sha1sum | trunc 8 -}} | ||
{{- end -}} |
Oops, something went wrong.