diff --git a/charts/hello-eks-anywhere/templates/_helpers.tpl b/charts/hello-eks-anywhere/templates/_helpers.tpl index 0caf0f9..392aeba 100644 --- a/charts/hello-eks-anywhere/templates/_helpers.tpl +++ b/charts/hello-eks-anywhere/templates/_helpers.tpl @@ -1,3 +1,66 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "hello-eks-anywhere.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "hello-eks-anywhere.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "hello-eks-anywhere.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "hello-eks-anywhere.labels" -}} +helm.sh/chart: {{ include "hello-eks-anywhere.chart" . }} +{{ include "hello-eks-anywhere.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "hello-eks-anywhere.selectorLabels" -}} +app.kubernetes.io/name: {{ include "hello-eks-anywhere.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "hello-eks-anywhere.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "hello-eks-anywhere.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + {{/* Create image name */}} diff --git a/charts/hello-eks-anywhere/templates/app.yaml b/charts/hello-eks-anywhere/templates/app.yaml deleted file mode 100644 index 314410d..0000000 --- a/charts/hello-eks-anywhere/templates/app.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: hello-eks-a - labels: - app: hello-eks-a -spec: - replicas: 1 - selector: - matchLabels: - app: hello-eks-a - template: - metadata: - labels: - app: hello-eks-a - spec: - containers: - - name: hello - image: {{.Values.sourceRegistry}}{{ template "template.image" .Values }} - imagePullPolicy: IfNotPresent - ports: - - containerPort: 80 - env: - - name: NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: TEST_CONFIG_1 - value: {{ .Values.config1 | quote}} - - name: TEST_CONFIG_2 - value: {{ .Values.config2 | quote}} - resources: - requests: - memory: "64Mi" - cpu: "250m" - limits: - memory: "128Mi" - cpu: "500m" ---- -apiVersion: v1 -kind: Service -metadata: - name: hello-eks-a -spec: - type: NodePort - selector: - app: hello-eks-a - ports: - - port: 80 \ No newline at end of file diff --git a/charts/hello-eks-anywhere/templates/deployment.yaml b/charts/hello-eks-anywhere/templates/deployment.yaml new file mode 100644 index 0000000..b796095 --- /dev/null +++ b/charts/hello-eks-anywhere/templates/deployment.yaml @@ -0,0 +1,42 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-eks-anywhere + labels: + app: hello-eks-anywhere +spec: + replicas: 1 + selector: + matchLabels: + app: hello-eks-anywhere + template: + metadata: + labels: + app: hello-eks-anywhere + spec: + containers: + - name: hello + image: {{.Values.sourceRegistry}}{{ template "template.image" .Values }} + imagePullPolicy: IfNotPresent + ports: + - containerPort: 80 + env: + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: TITLE + value: {{ .Values.title | quote}} + - name: SUBTITLE + value: {{ .Values.subtitle | quote}} + resources: + requests: + memory: "64Mi" + cpu: "250m" + limits: + memory: "128Mi" + cpu: "500m" diff --git a/charts/hello-eks-anywhere/templates/service.yaml b/charts/hello-eks-anywhere/templates/service.yaml new file mode 100644 index 0000000..2b8de9d --- /dev/null +++ b/charts/hello-eks-anywhere/templates/service.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "hello-eks-anywhere.fullname" . }} +spec: + type: LoadBalancer + selector: + app: hello-eks-anywhere + ports: + - port: 80 diff --git a/charts/hello-eks-anywhere/templates/tests/test-connection.yaml b/charts/hello-eks-anywhere/templates/tests/test-connection.yaml new file mode 100644 index 0000000..8969f13 --- /dev/null +++ b/charts/hello-eks-anywhere/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "hello-eks-anywhere.fullname" . }}-test-connection" + labels: + {{- include "hello-eks-anywhere.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: curl + image: public.ecr.aws/eks-distro-build-tooling/eks-distro-base:latest + command: ['curl'] + args: ['{{ include "hello-eks-anywhere.fullname" . }}:80'] + restartPolicy: Never diff --git a/charts/hello-eks-anywhere/values.yaml b/charts/hello-eks-anywhere/values.yaml index f0481b8..1570f59 100644 --- a/charts/hello-eks-anywhere/values.yaml +++ b/charts/hello-eks-anywhere/values.yaml @@ -1,11 +1,6 @@ namespace: eksa-packages - sourceRegistry: "public.ecr.aws/aws-containers" - repository: "hello-eks-anywhere" - tag: "{{hello-eks-anywhere}}" - -config1: "test1" - -config2: "test2" +title: "Amazon EKS Anywhere" +subtitle: "Run EKS in your datacenter"