Skip to content

Commit

Permalink
fix ports and configs in Helm chart to support latest LocalStack vers…
Browse files Browse the repository at this point in the history
…ion (#1)
  • Loading branch information
macnev2013 authored Dec 8, 2020
1 parent fadaddc commit c6e04cd
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 481 deletions.
1 change: 1 addition & 0 deletions chart/localstack/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
Expand Down
19 changes: 11 additions & 8 deletions chart/localstack/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
apiVersion: v1
annotations:
category: Infrastructure
apiVersion: v2
appVersion: "latest"
description: A Helm chart for Localstack
version: 0.1.1
name: localstack
version: 0.1.0
description: A fully functional local AWS cloud stack
type: application
keywords:
- aws
- localstack
sources:
- https://localstack.cloud/
- https://github.com/localstack/localstack
keywords:
- aws
- localstack
icon: https://github.com/localstack/localstack/raw/master/localstack/dashboard/web/img/localstack.png
maintainers:
- name: sidhuko
email: james.thomas.sidhu@gmail.com
- name: Waldemar Hummer
email: waldemar.hummer@gmail.com
11 changes: 6 additions & 5 deletions chart/localstack/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range $.Values.ingress.paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ . }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
Expand All @@ -11,11 +11,12 @@
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ include "localstack.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "localstack.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "localstack.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "localstack.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "localstack.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
62 changes: 46 additions & 16 deletions chart/localstack/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,32 +1,62 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "localstack.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- 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 "localstack.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 -}}
{{- 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 "localstack.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "localstack.labels" -}}
helm.sh/chart: {{ include "localstack.chart" . }}
{{ include "localstack.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "localstack.selectorLabels" -}}
app.kubernetes.io/name: {{ include "localstack.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "localstack.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "localstack.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
117 changes: 42 additions & 75 deletions chart/localstack/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,97 +3,73 @@ kind: Deployment
metadata:
name: {{ include "localstack.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "localstack.name" . }}
helm.sh/chart: {{ include "localstack.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "localstack.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "localstack.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "localstack.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "localstack.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "localstack.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "localstack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.localstack.port }}
- name: edgeport
containerPort: {{ .Values.service.edgePort }}
protocol: TCP
- name: esport
containerPort: {{ .Values.service.esPort }}
protocol: TCP
{{- range $index, $val := .Values.localstack.services }}
- name: {{ $val.name }}
containerPort: {{ $val.internalPort }}
{{- end }}
livenessProbe:
httpGet:
path: /
port: http
path: /health
port: edgeport
readinessProbe:
httpGet:
path: /
port: http
path: /health
port: edgeport
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: USE_SSL
value: !!string {{ .Values.localstack.useSsl }}
- name: SERVICES
value: "{{- range $index, $val := .Values.localstack.services -}}
{{- if $index -}},{{- end -}}{{- $val.name -}}:{{- $val.internalPort -}}
{{- end -}}"
{{- $root := . -}}
{{- with .Values.localstack }}
{{- if .defaultRegion }}
- name: DEFAULT_REGION
value: {{ .defaultRegion | quote}}
{{- end }}
- name: HOST_EXTERNAL
{{- if .hostExternal }}
value: {{.hostExternal | quote}}
{{- else }}
value: "{{- template "localstack.fullname" $root -}}.{{- $root.Release.Namespace -}}"
{{- end }}
{{- if .kinesisErrorProbability }}
- name: DEBUG
value: {{ ternary "1" "0" .Values.debug | quote }}
{{- if .Values.kinesisErrorProbability }}
- name: KINESIS_ERROR_PROBABILITY
value: {{.kinesisErrorProbability | quote}}
{{- end }}
{{- if .dynamodbErrorProbability }}
- name: DYNAMODB_ERROR_PROBABILITY
value: {{.dynamodbErrorProbability | quote}}
{{- end }}
{{- if .lambdaExecutor }}
value: {{ .Values.kinesisErrorProbability | quote }}
{{- end }}
{{- if .Values.lambdaExecutor }}
- name: LAMBDA_EXECUTOR
value: {{.lambdaExecutor | quote }}
{{- end }}
{{- range $key, $val := .services -}}
{{- if $val.enabled }}
{{- if $val.endpoint }}
- name: {{$val.name | upper}}_BACKEND
value: {{$val.endpoint | quote}}
{{- end }}
{{- end }}
{{- end -}}
value: {{ .Values.lambdaExecutor | quote }}
{{- end }}
{{- if .Values.persistence.enabled }}
{{- if .Values.dataDir }}
- name: DATA_DIR
value: "/tmp/localstack/data"
value: {{ .Values.dataDir | quote }}
{{- end }}
{{- if .Values.startServices }}
- name: SERVICES
value: {{ .Values.startServices | quote }}
{{- end }}
{{- if .Values.extraEnvVars }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
- name: PORT_WEB_UI
value: {{ .Values.localstack.port | quote }}
# @todo ensure correct
# {{- if .Values.persistence.mounts }}
# {{ toYaml .Values.persistence.mounts | indent 12 }}
# {{- end }}
volumeMounts:
- name: datadir
mountPath: /tmp/localstack
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand All @@ -106,12 +82,3 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
# @todo ensure correct
volumes:
- name: datadir
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim | default (include "localstack.fullname" .)}}
{{- else }}
emptyDir: {}
{{- end }}
17 changes: 9 additions & 8 deletions chart/localstack/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "localstack.fullname" . -}}
{{- $ingressPaths := .Values.ingress.paths -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app.kubernetes.io/name: {{ include "localstack.name" . }}
helm.sh/chart: {{ include "localstack.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "localstack.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand All @@ -27,14 +28,14 @@ spec:
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . | quote }}
- host: {{ .host | quote }}
http:
paths:
{{- range $ingressPaths }}
{{- range .paths }}
- path: {{ . }}
backend:
serviceName: {{ $fullName }}
servicePort: http
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
24 changes: 0 additions & 24 deletions chart/localstack/templates/pvc.yaml

This file was deleted.

Loading

0 comments on commit c6e04cd

Please sign in to comment.