Skip to content

Commit

Permalink
Merge pull request #11 from Mirantis/templates
Browse files Browse the repository at this point in the history
Add basic k0smotron+aws template
  • Loading branch information
Kshatrix authored Jun 5, 2024
2 parents 2af2723 + b53e3a6 commit 19f1451
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v2
name: hmc-template-hosted-control-planes
description: |
The HMC template to deploy kubernetes cluster with control plane components
within the management cluster.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.1.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- define "cluster.name" -}}
{{- .Values.clusterName | trunc 63 }}
{{- end }}

{{- define "awsmachinetemplate.name" -}}
{{- include "cluster.name" . }}-mt
{{- end }}

{{- define "k0smotroncontrolplane.name" -}}
{{- include "cluster.name" . }}-cp
{{- end }}

{{- define "k0sworkerconfigtemplate.name" -}}
{{- include "cluster.name" . }}-machine-config
{{- end }}

{{- define "machinedeployment.name" -}}
{{- include "cluster.name" . }}-md
{{- end }}

{{- define "k0sconfig.name" -}}
{{- include "cluster.name" . }}-k0sconfig
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSCluster
metadata:
name: {{ include "cluster.name" . }}
annotations:
cluster.x-k8s.io/managed-by: k0smotron
spec:
region: {{ .Values.region }}
# identityRef:
# kind: AWSClusterStaticIdentity
# name: aws-identity-name
network:
vpc:
id: {{ .Values.vpcID }}
{{- with .Values.subnets }}
subnets:
{{- toYaml . | nindent 6 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSMachineTemplate
metadata:
name: {{ include "awsmachinetemplate.name" . }}
spec:
template:
spec:
ami:
id: {{ .Values.amiID }}
instanceType: {{ .Values.instanceType }}
# Instance Profile created by `clusterawsadm bootstrap iam create-cloudformation-stack`
iamInstanceProfile: {{ .Values.iamInstanceProfile }}
cloudInit:
# Makes CAPA use k0s bootstrap cloud-init directly and not via SSM
# Simplifies the VPC setup as we do not need custom SSM endpoints etc.
insecureSkipSecretsManager: true
additionalSecurityGroups:
- id: {{ .Values.securityGroupID }}
{{- if .Values.sshKeyName }}
sshKeyName: {{ .Values.sshKeyName }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: {{ include "cluster.name" . }}
spec:
{{- with .Values.clusterNetwork }}
clusterNetwork:
{{- toYaml . | nindent 4 }}
{{- end }}
controlPlaneRef:
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: K0smotronControlPlane
name: {{ include "k0smotroncontrolplane.name" . }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSCluster
name: {{ include "cluster.name" . }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: K0smotronControlPlane
metadata:
name: {{ include "k0smotroncontrolplane.name" . }}
spec:
replicas: 3
# dirty hack
version: {{ .Values.k0s.version | replace "+" "-" }}
{{- with .Values.k0smotron.service }}
service:
{{- toYaml . | nindent 4 }}
{{- end }}
controllerPlaneFlags:
- "--enable-cloud-provider=true"
- "--debug=true"
k0sConfig:
apiVersion: k0s.k0sproject.io/v1beta1
kind: ClusterConfig
metadata:
name: {{ include "k0sconfig.name" . }}
namespace: {{ .Release.Namespace }}
spec:
extensions:
helm:
repositories:
- name: aws-cloud-controller-manager
url: https://kubernetes.github.io/cloud-provider-aws
charts:
- name: aws-cloud-controller-manager
namespace: kube-system
chartname: aws-cloud-controller-manager/aws-cloud-controller-manager
version: "0.0.8"
values: |
args:
- --v=2
- --cloud-provider=aws
- --cluster-cidr={{ first .Values.clusterNetwork.pods.cidrBlocks }}
- --allocate-node-cidrs=true
- --cluster-name={{ include "cluster.name" . }}
# Removing the default `node-role.kubernetes.io/control-plane` node selector
# TODO: it does not work
# nodeSelector: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: K0sWorkerConfigTemplate
metadata:
name: {{ include "k0sworkerconfigtemplate.name" . }}
spec:
template:
spec:
version: {{ .Values.k0s.version }}
args:
- --enable-cloud-provider
- --kubelet-extra-args="--cloud-provider=external --hostname-override=$(hostname --fqdn)"
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: {{ include "machinedeployment.name" . }}
spec:
clusterName: {{ include "cluster.name" . }}
replicas: {{ .Values.workersNumber }}
selector:
matchLabels:
cluster.x-k8s.io/cluster-name: {{ include "cluster.name" . }}
template:
metadata:
labels:
cluster.x-k8s.io/cluster-name: {{ include "cluster.name" . }}
spec:
clusterName: {{ include "cluster.name" . }}
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: K0sWorkerConfigTemplate
name: {{ include "k0sworkerconfigtemplate.name" . }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSMachineTemplate
name: {{ include "awsmachinetemplate.name" . }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Cluster parameters
clusterName: k0s-aws
workersNumber: 2

clusterNetwork:
pods:
cidrBlocks:
- "10.244.0.0/16"
services:
cidrBlocks:
- "10.96.0.0/12"

# AWS cluster parameters
vpcID: ""
region: ""
sshKeyName: ""
subnets: []

# AWS machines parameters
amiID: ""
iamInstanceProfile: nodes.cluster-api-provider-aws.sigs.k8s.io
instanceType: ""
securityGroupID: ""

# K0smotron parameters
k0smotron:
service:
type: LoadBalancer
apiPort: 6443
konnectivityPort: 8132

# K0s parameters
k0s:
version: v1.27.2+k0s.0

0 comments on commit 19f1451

Please sign in to comment.