Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
first implementation of lagoon-remote helmchart
Browse files Browse the repository at this point in the history
  • Loading branch information
Schnitzel committed Feb 9, 2020
1 parent 161f218 commit 40afeb2
Show file tree
Hide file tree
Showing 23 changed files with 379 additions and 215 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ deploytest
*.retry
startVagrant.sh
local-dev/oc
local-dev/helm
minishift
minikube
k3d
Expand Down
24 changes: 16 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ MINISHIFT_DISK_SIZE := 30GB
# Version and Hash of the minikube cli that should be downloaded
K3S_VERSION := v1.17.0-k3s.1
KUBECTL_VERSION := v1.17.0
HELM_VERSION := v3.0.3
MINIKUBE_VERSION := 1.5.2
MINIKUBE_PROFILE := $(CI_BUILD_TAG)-minikube
MINIKUBE_CPUS := 6
Expand Down Expand Up @@ -986,14 +987,27 @@ endif
# installed, otherwise downloads it.
local-dev/kubectl:
ifeq ($(KUBECTL_VERSION), $(shell kubectl version --short --client 2>/dev/null | sed -E 's/Client Version: v([0-9.]+).*/\1/'))
$(info linking local kubectl version $(K3D_VERSION))
$(info linking local kubectl version $(KUBECTL_VERSION))
ln -s $(shell command -v kubectl) ./local-dev/kubectl
else
$(info downloading kubectl version $(KUBECTL_VERSION) for $(ARCH))
curl -Lo local-dev/kubectl https://storage.googleapis.com/kubernetes-release/release/$(KUBECTL_VERSION)/bin/$(ARCH)/amd64/kubectl
chmod a+x local-dev/kubectl
endif

# Symlink the installed helm client if the correct version is already
# installed, otherwise downloads it.
local-dev/helm:
@mkdir -p ./local-dev/helm
ifeq ($(HELM_VERSION), $(shell helm version --short --client 2>/dev/null | sed -E 's/v([0-9.]+).*/\1/'))
$(info linking local helm version $(HELM_VERSION))
ln -s $(shell command -v helm) ./local-dev/helm
else
$(info downloading helm version $(HELM_VERSION) for $(ARCH))
curl -L https://get.helm.sh/helm-$(HELM_VERSION)-$(ARCH)-amd64.tar.gz | tar xzC local-dev/helm --strip-components=1
chmod a+x local-dev/helm/helm
endif

k3d: local-dev/k3d local-dev/kubectl build/docker-host
$(MAKE) local-registry-up
$(info starting k3d with name $(K3D_NAME))
Expand All @@ -1014,13 +1028,7 @@ endif
docker tag $(CI_BUILD_TAG)/docker-host localhost:5000/lagoon/docker-host; \
docker push localhost:5000/lagoon/docker-host; \
local-dev/kubectl create namespace lagoon; \
local-dev/kubectl -n lagoon create -f kubernetes-setup/sa-kubernetesbuilddeploy.yaml; \
local-dev/kubectl -n lagoon create -f kubernetes-setup/priorityclasses.yaml; \
local-dev/kubectl -n lagoon create -f kubernetes-setup/k3d-docker-host.yaml; \
local-dev/kubectl -n lagoon create -f kubernetes-setup/sa-lagoon-deployer.yaml; \
local-dev/kubectl -n lagoon create -f kubernetes-setup/role-mariadb-operator.yaml; \
local-dev/kubectl -n dbaas-operator-system create -f kubernetes-setup/dbaas-operator.yaml; \
local-dev/kubectl -n lagoon create -f kubernetes-setup/dbaas-providers.yaml; \
local-dev/helm/helm upgrade --install -n lagoon lagoon-remote ./helmcharts/lagoon-remote --set dockerHost.image.name=172.17.0.1:5000/lagoon/docker-host --set dockerHost.registry=172.17.0.1:5000; \
local-dev/kubectl -n lagoon rollout status deployment docker-host -w;
ifeq ($(ARCH), darwin)
export KUBECONFIG="$$(./local-dev/k3d get-kubeconfig --name='$(K3D_NAME)')"; \
Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions charts/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
entries:
lagoon-remote:
- apiVersion: v2
appVersion: 1.4.0
created: "2020-02-09T15:27:12.333584-06:00"
description: A Helm chart to run a lagoon-remote
digest: cc8f78b72b59fc9b68c697c3731d8fef9848831ec1ffe1ae92bcaa00ea64d2d2
name: lagoon-remote
type: application
urls:
- lagoon-remote-0.1.0.tgz
version: 0.1.0
generated: "2020-02-09T15:27:12.330134-06:00"
Binary file added charts/lagoon-remote-0.1.0.tgz
Binary file not shown.
22 changes: 22 additions & 0 deletions charts/lagoon-remote/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
21 changes: 21 additions & 0 deletions charts/lagoon-remote/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
name: lagoon-remote
description: A Helm chart to run a lagoon-remote

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
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.
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.
appVersion: 1.4.0
73 changes: 73 additions & 0 deletions charts/lagoon-remote/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "lagoon-remote.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 "lagoon-remote.dockerHost.fullname" -}}
{{- .Values.dockerHost.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "lagoon-remote.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

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

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "lagoon-remote.dockerHost.serviceAccountName" -}}
{{- if .Values.dockerHost.serviceAccount.create -}}
{{ default (include "lagoon-remote.dockerHost.fullname" .) .Values.dockerHost.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.dockerHost.serviceAccount.name }}
{{- end -}}
{{- end -}}


{{/*
Create the name of the service account to use
*/}}
{{- define "lagoon-remote.kubernetesbuilddeploy.serviceAccountName" -}}
{{ .Values.kubernetesbuilddeploy.serviceAccountName }}
{{- end -}}
84 changes: 84 additions & 0 deletions charts/lagoon-remote/templates/docker-host-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "lagoon-remote.dockerHost.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
labels:
{{- include "lagoon-remote.dockerHost.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.dockerHost.replicaCount }}
selector:
matchLabels:
{{- include "lagoon-remote.dockerHost.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "lagoon-remote.dockerHost.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "lagoon-remote.dockerHost.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.dockerHost.podSecurityContext | nindent 8 }}
containers:
- name: {{ include "lagoon-remote.dockerHost.fullname" . }}
securityContext:
{{- toYaml .Values.dockerHost.securityContext | nindent 12 }}
image: {{ .Values.dockerHost.image.name | quote }}
imagePullPolicy: {{ .Values.dockerHost.image.pullPolicy }}
env:
- name: DOCKER_HOST
value: localhost
- name: REGISTRY
value: {{ .Values.dockerHost.registry | quote }}
- name: REPOSITORY_TO_UPDATE
value: {{ .Values.dockerHost.repositoryToUpdate | quote }}
- name: CRONJOBS
value: |
22 1 * * * /lagoon/cronjob.sh "/prune-images.sh"
22 */4 * * * /lagoon/cronjob.sh "/remove-exited.sh"
*/15 * * * * /lagoon/cronjob.sh "/update-push-images.sh"
ports:
- containerPort: 2375
protocol: TCP
livenessProbe:
failureThreshold: 3
periodSeconds: 10
successThreshold: 1
tcpSocket:
port: 2375
timeoutSeconds: 1
readinessProbe:
failureThreshold: 3
periodSeconds: 10
successThreshold: 1
tcpSocket:
port: 2375
timeoutSeconds: 1
resources:
{{- toYaml .Values.dockerHost.resources | nindent 12 }}
volumeMounts:
- mountPath: /var/lib/docker
name: docker-lib
volumes:
- name: docker-lib
{{- if .Values.dockerHost.storage.create }}
persistentVolumeClaim:
claimName: {{ include "lagoon-remote.dockerHost.fullname" . }}
{{- else }}
emptyDir: {}
{{- end -}}
{{- with .Values.dockerHost.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.dockerHost.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.dockerHost.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
14 changes: 14 additions & 0 deletions charts/lagoon-remote/templates/docker-host-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.dockerHost.storage.create -}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "lagoon-remote.dockerHost.fullname" . }}
labels:
{{- include "lagoon-remote.dockerHost.labels" . | nindent 4 }}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.dockerHost.storage.size | quote }}
{{- end -}}
15 changes: 15 additions & 0 deletions charts/lagoon-remote/templates/docker-host-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "lagoon-remote.dockerHost.fullname" . }}
labels:
{{- include "lagoon-remote.dockerHost.labels" . | nindent 4 }}
spec:
type: {{ .Values.dockerHost.service.type }}
ports:
- port: {{ .Values.dockerHost.service.port }}
targetPort: 2375
protocol: TCP
name: docker-daemon-tcp
selector:
{{- include "lagoon-remote.dockerHost.selectorLabels" . | nindent 4 }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- if .Values.dockerHost.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "lagoon-remote.dockerHost.serviceAccountName" . }}
labels:
{{ include "lagoon-remote.dockerHost.labels" . | nindent 4 }}
{{- end -}}
24 changes: 24 additions & 0 deletions charts/lagoon-remote/templates/priorityclasses.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
apiVersion: scheduling.k8s.io/v1beta1
kind: PriorityClass
metadata:
name: lagoon-priority-production
value: 1000000
globalDefault: true
description: "This priority class should be used for production environments."
---
apiVersion: scheduling.k8s.io/v1beta1
kind: PriorityClass
metadata:
name: lagoon-priority-staging
value: 100000
globalDefault: false
description: "This priority class should be used for staging environments."
---
apiVersion: scheduling.k8s.io/v1beta1
kind: PriorityClass
metadata:
name: lagoon-priority-development
value: 10000
globalDefault: false
description: "This priority class should be used for development environments."
13 changes: 13 additions & 0 deletions charts/lagoon-remote/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "lagoon-remote.kubernetesbuilddeploy.serviceAccountName" . }}
namespace: {{ .Release.Namespace | quote }}
subjects:
- kind: ServiceAccount
name: {{ include "lagoon-remote.kubernetesbuilddeploy.serviceAccountName" . }}
namespace: {{ .Release.Namespace | quote }}
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
7 changes: 7 additions & 0 deletions charts/lagoon-remote/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "lagoon-remote.kubernetesbuilddeploy.serviceAccountName" . }}
namespace: {{ .Release.Namespace | quote }}
labels:
{{ include "lagoon-remote.labels" . | nindent 4 }}
Loading

0 comments on commit 40afeb2

Please sign in to comment.