Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove faulty regex and remove labels from awsmachinetemplate specs #401

Merged
merged 4 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Move labels to AWSMachineTemplate manifest to avoid unnecessary rolling/no rolling.

### Added

- Add teleport.service: Secure SSH access via Teleport.
Expand Down
62 changes: 31 additions & 31 deletions helm/cluster-aws/templates/_bastion.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,28 @@ This function is used for both the `.Spec` value and as the data for the hash fu
Any changes to this will trigger the resource to be recreated rather than attempting to update in-place.
*/}}
{{- define "bastion-awsmachinetemplate-spec" -}}
template:
metadata:
labels:
cluster.x-k8s.io/role: bastion
{{- include "labels.common" $ | nindent 6 }}
spec:
instanceType: {{ .Values.connectivity.bastion.instanceType }}
cloudInit: {}
imageLookupBaseOS: flatcar-stable
imageLookupFormat: {{ "capa-ami-{{.BaseOS}}-v{{.K8sVersion}}-gs" }}
imageLookupOrg: "{{ .Values.providerSpecific.flatcarAwsAccount }}"
iamInstanceProfile: {{ include "resource.default.name" $ }}-bastion
publicIP: {{ if eq .Values.connectivity.vpcMode "private" }}false{{else}}true{{end}}
sshKeyName: ""
subnet:
filters:
- name: tag:{{ if eq .Values.connectivity.vpcMode "private" }}github.com/giantswarm/aws-vpc-operator/role{{else}}sigs.k8s.io/cluster-api-provider-aws/role{{end}}
values:
- {{ if eq .Values.connectivity.vpcMode "private" }}private{{else}}public{{end}}
- name: tag:{{ if eq .Values.connectivity.vpcMode "private" }}github.com/giantswarm/aws-vpc-operator/{{else}}sigs.k8s.io/cluster-api-provider-aws/cluster/{{end}}{{ include "resource.default.name" $ }}
values:
- owned
- shared
{{- range $i, $tags := .Values.connectivity.bastion.subnetTags }}
- name: tag:{{ keys $tags | first }}
values:
- {{ index $tags (keys $tags | first) | quote }}
{{- end }}
instanceType: {{ .Values.connectivity.bastion.instanceType }}
cloudInit: {}
imageLookupBaseOS: flatcar-stable
imageLookupFormat: {{ "capa-ami-{{.BaseOS}}-v{{.K8sVersion}}-gs" }}
imageLookupOrg: "{{ .Values.providerSpecific.flatcarAwsAccount }}"
iamInstanceProfile: {{ include "resource.default.name" $ }}-bastion
publicIP: {{ if eq .Values.connectivity.vpcMode "private" }}false{{else}}true{{end}}
sshKeyName: ""
subnet:
filters:
- name: tag:{{ if eq .Values.connectivity.vpcMode "private" }}github.com/giantswarm/aws-vpc-operator/role{{else}}sigs.k8s.io/cluster-api-provider-aws/role{{end}}
values:
- {{ if eq .Values.connectivity.vpcMode "private" }}private{{else}}public{{end}}
- name: tag:{{ if eq .Values.connectivity.vpcMode "private" }}github.com/giantswarm/aws-vpc-operator/{{else}}sigs.k8s.io/cluster-api-provider-aws/cluster/{{end}}{{ include "resource.default.name" $ }}
values:
- owned
- shared
{{- range $i, $tags := .Values.connectivity.bastion.subnetTags }}
- name: tag:{{ keys $tags | first }}
values:
- {{ index $tags (keys $tags | first) | quote }}
{{- end }}
{{- end }}

{{- define "bastion-kubeadmconfigtemplate-spec" -}}
Expand Down Expand Up @@ -92,7 +86,7 @@ spec:
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AWSMachineTemplate
name: {{ include "resource.default.name" $ }}-bastion-{{ include "hash" (dict "data" (include "bastion-awsmachinetemplate-spec" $ | mustRegexReplaceAll "helm.sh/chart: .*" "") "global" .) }}
name: {{ include "resource.default.name" $ }}-bastion-{{ include "hash" (dict "data" (include "bastion-awsmachinetemplate-spec" $) "global" .) }}
version: {{ .Values.internal.kubernetesVersion }}
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
Expand All @@ -102,9 +96,15 @@ metadata:
cluster.x-k8s.io/role: bastion
{{- include "labels.common" $ | nindent 4 }}
app.kubernetes.io/version: {{ .Chart.Version | quote }}
name: {{ include "resource.default.name" $ }}-bastion-{{ include "hash" (dict "data" (include "bastion-awsmachinetemplate-spec" $ | mustRegexReplaceAll "helm.sh/chart: .*" "") "global" .) }}
name: {{ include "resource.default.name" $ }}-bastion-{{ include "hash" (dict "data" (include "bastion-awsmachinetemplate-spec" $) "global" .) }}
namespace: {{ .Release.Namespace }}
spec: {{ include "bastion-awsmachinetemplate-spec" $ | nindent 2 }}
spec:
template:
metadata:
labels:
cluster.x-k8s.io/role: bastion
{{- include "labels.common" $ | nindent 8 }}
spec:{{- include "controlplane-awsmachinetemplate-spec" $ | nindent 6 }}
bdehri marked this conversation as resolved.
Show resolved Hide resolved
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
Expand Down
98 changes: 49 additions & 49 deletions helm/cluster-aws/templates/_control_plane.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,47 @@ This function is used for both the `.Spec` value and as the data for the hash fu
Any changes to this will trigger the resource to be recreated rather than attempting to update in-place.
*/}}
{{- define "controlplane-awsmachinetemplate-spec" -}}
template:
metadata:
labels:
cluster.x-k8s.io/role: control-plane
{{- include "labels.common" $ | nindent 6 }}
spec:
{{- include "ami" $ | nindent 4 }}
cloudInit: {}
instanceType: {{ .Values.controlPlane.instanceType }}
nonRootVolumes:
- deviceName: /dev/xvdc
encrypted: true
size: {{ .Values.controlPlane.etcdVolumeSizeGB }}
type: gp3
- deviceName: /dev/xvdd
encrypted: true
size: {{ .Values.controlPlane.containerdVolumeSizeGB }}
type: gp3
- deviceName: /dev/xvde
encrypted: true
size: {{ .Values.controlPlane.kubeletVolumeSizeGB }}
type: gp3
rootVolume:
size: {{ .Values.controlPlane.rootVolumeSizeGB }}
type: gp3
iamInstanceProfile: control-plane-{{ include "resource.default.name" $ }}
{{- if .Values.controlPlane.additionalSecurityGroups }}
additionalSecurityGroups:
{{- toYaml .Values.controlPlane.additionalSecurityGroups | nindent 4 }}
{{- include "ami" $ }}
cloudInit: {}
instanceType: {{ .Values.controlPlane.instanceType }}
nonRootVolumes:
- deviceName: /dev/xvdc
encrypted: true
size: {{ .Values.controlPlane.etcdVolumeSizeGB }}
type: gp3
- deviceName: /dev/xvdd
encrypted: true
size: {{ .Values.controlPlane.containerdVolumeSizeGB }}
type: gp3
- deviceName: /dev/xvde
encrypted: true
size: {{ .Values.controlPlane.kubeletVolumeSizeGB }}
type: gp3
rootVolume:
size: {{ .Values.controlPlane.rootVolumeSizeGB }}
type: gp3
iamInstanceProfile: control-plane-{{ include "resource.default.name" $ }}
{{- if .Values.controlPlane.additionalSecurityGroups }}
additionalSecurityGroups:
{{- toYaml .Values.controlPlane.additionalSecurityGroups | nindent 2 }}
{{- end }}
sshKeyName: ""
subnet:
filters:
- name: tag:kubernetes.io/cluster/{{ include "resource.default.name" $ }}
values:
- shared
- owned
{{ if eq $.Values.connectivity.vpcMode "public" }}
- name: tag:sigs.k8s.io/cluster-api-provider-aws/role
values:
- private
{{end}}
{{- range $i, $tags := .Values.controlPlane.subnetTags }}
- name: tag:{{ keys $tags | first }}
values:
- {{ index $tags (keys $tags | first) | quote }}
{{- end }}
sshKeyName: ""
subnet:
filters:
- name: tag:kubernetes.io/cluster/{{ include "resource.default.name" $ }}
values:
- shared
- owned
{{ if eq $.Values.connectivity.vpcMode "public" }}
- name: tag:sigs.k8s.io/cluster-api-provider-aws/role
values:
- private
{{end}}
{{- range $i, $tags := .Values.controlPlane.subnetTags }}
- name: tag:{{ keys $tags | first }}
values:
- {{ index $tags (keys $tags | first) | quote }}
{{- end }}
{{- end }}

{{- define "control-plane" }}
Expand All @@ -73,7 +67,7 @@ spec:
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AWSMachineTemplate
name: {{ include "resource.default.name" $ }}-control-plane-{{ include "hash" (dict "data" (include "controlplane-awsmachinetemplate-spec" $ | mustRegexReplaceAll "helm.sh/chart: .*" "") "global" .) }}
name: {{ include "resource.default.name" $ }}-control-plane-{{ include "hash" (dict "data" (include "controlplane-awsmachinetemplate-spec" $) "global" .) }}
kubeadmConfigSpec:
format: ignition
ignition:
Expand Down Expand Up @@ -259,7 +253,13 @@ metadata:
cluster.x-k8s.io/role: control-plane
{{- include "labels.common" $ | nindent 4 }}
app.kubernetes.io/version: {{ .Chart.Version | quote }}
name: {{ include "resource.default.name" $ }}-control-plane-{{ include "hash" (dict "data" (include "controlplane-awsmachinetemplate-spec" $ | mustRegexReplaceAll "helm.sh/chart: .*" "") "global" .) }}
name: {{ include "resource.default.name" $ }}-control-plane-{{ include "hash" (dict "data" (include "controlplane-awsmachinetemplate-spec" $) "global" .) }}
namespace: {{ $.Release.Namespace }}
spec: {{ include "controlplane-awsmachinetemplate-spec" $ | nindent 2 }}
spec:
template:
metadata:
labels:
cluster.x-k8s.io/role: control-plane
{{- include "labels.common" $ | nindent 8 }}
spec:{{- include "controlplane-awsmachinetemplate-spec" $ | nindent 6 }}
{{- end -}}