Merge "debian: add Docker service to helm chart"

This commit is contained in:
Zuul
2022-03-10 19:00:41 +00:00
committed by Gerrit Code Review
13 changed files with 302 additions and 7 deletions

View File

@@ -33,3 +33,6 @@ dependencies:
- name: stx-repomgr
version: "0.1.0"
repository: "file://dependency_chart/stx-aptly/stx-repomgr"
- name: stx-docker
version: "0.1.0"
repository: "file://dependency_chart/stx-docker"

View File

@@ -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/

View File

@@ -0,0 +1,24 @@
---
apiVersion: v2
name: stx-docker
description: A Helm chart for the docker daemon in StarlingX build environment
# 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.
# 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.
appVersion: 1.16.0

View File

@@ -0,0 +1,63 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "stx-docker.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 "stx-docker.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 "stx-docker.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "stx-docker.labels" -}}
helm.sh/chart: {{ include "stx-docker.chart" . }}
{{ include "stx-docker.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "stx-docker.selectorLabels" -}}
app.kubernetes.io/name: {{ include "stx-docker.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "stx-docker.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "stx-docker.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,71 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "stx-docker.fullname" . }}
labels:
{{- include "stx-docker.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "stx-docker.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "stx-docker.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
tty: true
env:
- name: DOCKER_TLS_CERTDIR
value: ""
command:
- "/usr/local/bin/dockerd-entrypoint.sh"
{{- range .Values.insecureRegistries }}
- "--insecure-registry={{ . }}"
{{- end }}
volumeMounts:
- name: shared-workspace
mountPath: {{ .Values.volumes.sharedWorkspace.mountPath }}
- name: docker-run
mountPath: {{ .Values.volumes.dockerRun.mountPath }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: shared-workspace
hostPath:
path: {{ .Values.global.hostDir }}{{ .Values.volumes.sharedWorkspace.hostPath }}
- name: docker-run
hostPath:
path: {{ .Values.global.hostDir }}{{ .Values.volumes.dockerRun.hostPath }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@@ -0,0 +1,16 @@
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "stx-docker.fullname" . }}
labels:
{{- include "stx-docker.labels" . | nindent 4 }}
spec:
type: {{ .Values.services.dockerDaemon.type }}
ports:
- port: {{ .Values.services.dockerDaemon.port }}
targetPort: 2375
protocol: TCP
name: docker-socket
selector:
{{- include "stx-repomgr.selectorLabels" . | nindent 4 }}

View File

@@ -0,0 +1,71 @@
# Default values for stx-lat-tool.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
---
replicaCount: 1
image:
repository: docker
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "20.10.12-dind"
volumes:
sharedWorkspace:
mountPath: /localdisk
hostPath: /localdisk
dockerRun:
mountPath: /var/run/docker
hostPath: /docker/run
services:
dockerDaemon:
type: ClusterIP
port: 2375
insecureRegistries:
# - "registry.address:port"
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext:
privileged: true
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
nodeSelector: {}
tolerations: []
affinity: {}

View File

@@ -34,6 +34,9 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.global.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
tty: true
env:
- name: DOCKER_HOST
value: "tcp://{{ .Release.Name }}-stx-docker"
volumeMounts:
- name: {{ .Values.volumeMounts.workspace.name }}
mountPath: {{ .Values.volumeMounts.workspace.mountPath}}