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

feat(deploy): Add Helm chart #31

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 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
23 changes: 23 additions & 0 deletions deploy/helm/virtink/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
6 changes: 6 additions & 0 deletions deploy/helm/virtink/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: virtink
description: A helm chart for installing virtink
type: application
version: 0.10.0
appVersion: "v0.10.0"
1 change: 1 addition & 0 deletions deploy/helm/virtink/crds
71 changes: 71 additions & 0 deletions deploy/helm/virtink/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "virtink.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 "virtink.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 "virtink.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{- define "virtink.image" -}}
{{- $registryName := .registry -}}
{{- $repositoryName := .repository -}}
{{- $tag := .tag | toString -}}
{{- $digest := .digest | toString -}}
{{- if $digest }}
{{- if $registryName }}
{{- printf "%s/%s@%s" $registryName $repositoryName $digest -}}
{{- else -}}
{{- printf "%s@%s" $repositoryName $digest -}}
{{- end -}}
{{- else -}}
{{- if $registryName }}
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- else -}}
{{- printf "%s:%s" $repositoryName $tag -}}
{{- end -}}
{{- end -}}
{{- end -}}
19 changes: 19 additions & 0 deletions deploy/helm/virtink/templates/virt-controller/cert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: virt-controller-cert
spec:
issuerRef:
kind: Issuer
name: virt-controller-cert-issuer
dnsNames:
- virt-controller.{{ .Release.Namespace }}.svc
- virt-controller.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}
secretName: virt-controller-cert
---
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: virt-controller-cert-issuer
spec:
selfSigned: {}
55 changes: 55 additions & 0 deletions deploy/helm/virtink/templates/virt-controller/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{{- $service := .Values.virtController }}
{{- $image := merge $service.image .Values.image }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: virt-controller
labels:
{{- include "virtink.labels" . | nindent 4 }}
app.kubernetes.io/component: virt-controller
spec:
selector:
matchLabels:
{{- include "virtink.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: virt-controller
template:
metadata:
{{- with $service.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "virtink.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: virt-controller
spec:
serviceAccountName: virt-controller
containers:
- name: virt-controller
image: {{ include "virtink.image" $image }}
imagePullPolicy: {{ $image.pullPolicy }}
args:
- --zap-time-encoding=iso8601
- --leader-elect
volumeMounts:
- name: cert
mountPath: /tmp/k8s-webhook-server/serving-certs
readOnly: true
resources:
{{- toYaml .Values.virtController.resources | nindent 12 }}
volumes:
- name: cert
secret:
secretName: virt-controller-cert
defaultMode: 0644
{{- with .Values.virtController.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.virtController.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.virtController.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
creationTimestamp: null
name: mutating-webhook-configuration
weixiao-huang marked this conversation as resolved.
Show resolved Hide resolved
name: virt-controller
annotations:
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/virt-controller-cert
webhooks:
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
name: virt-controller
namespace: {{ .Release.Namespace }}
path: /mutate-v1alpha1-virtualmachine
failurePolicy: Fail
name: mutate.virtualmachine.v1alpha1.virt.virtink.smartx.com
Expand All @@ -31,15 +33,17 @@ apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
creationTimestamp: null
name: validating-webhook-configuration
name: virt-controller
weixiao-huang marked this conversation as resolved.
Show resolved Hide resolved
annotations:
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/virt-controller-cert
webhooks:
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
name: virt-controller
namespace: {{ .Release.Namespace }}
path: /validate-v1alpha1-virtualmachine
failurePolicy: Fail
name: validate.virtualmachine.v1alpha1.virt.virtink.smartx.com
Expand All @@ -59,8 +63,8 @@ webhooks:
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
name: virt-controller
namespace: {{ .Release.Namespace }}
path: /validate-v1alpha1-virtualmachinemigration
failurePolicy: Fail
name: validate.virtualmachinemigration.v1alpha1.virt.virtink.smartx.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ roleRef:
subjects:
- kind: ServiceAccount
name: virt-controller
namespace: virtink-system
namespace: {{ .Release.Namespace }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: virt-controller
14 changes: 14 additions & 0 deletions deploy/helm/virtink/templates/virt-controller/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: virt-daemon
weixiao-huang marked this conversation as resolved.
Show resolved Hide resolved
labels:
{{- include "virtink.labels" . | nindent 4 }}
app.kubernetes.io/component: virt-daemon
weixiao-huang marked this conversation as resolved.
Show resolved Hide resolved
spec:
selector:
{{- include "virtink.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: virt-daemon
weixiao-huang marked this conversation as resolved.
Show resolved Hide resolved
ports:
- port: 443
targetPort: 9443
19 changes: 19 additions & 0 deletions deploy/helm/virtink/templates/virt-daemon/cert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: virt-daemon-cert
spec:
issuerRef:
kind: Issuer
name: virt-daemon-cert-issuer
dnsNames:
- virt-daemon.{{ .Release.Namespace }}.svc
- virt-daemon.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}
secretName: virt-daemon-cert
---
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: virt-daemon-cert-issuer
spec:
selfSigned: {}
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
{{- $service := .Values.virtDaemon }}
{{- $image := merge $service.image .Values.image }}
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: virt-daemon
namespace: virtink-system
labels:
app.kubernetes.io/component: virt-daemon
spec:
selector:
matchLabels:
name: virt-daemon
{{- include "virtink.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: virt-daemon
template:
metadata:
{{- with $service.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
name: virt-daemon
{{- include "virtink.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: virt-daemon
spec:
serviceAccountName: virt-daemon
containers:
- name: virt-daemon
image: virt-daemon
image: {{ include "virtink.image" $image }}
imagePullPolicy: {{ $image.pullPolicy }}
env:
- name: NODE_NAME
valueFrom:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ roleRef:
subjects:
- kind: ServiceAccount
name: virt-daemon
namespace: virtink-system
namespace: {{ .Release.Namespace }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: virt-daemon
57 changes: 57 additions & 0 deletions deploy/helm/virtink/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Default values for virtink.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

virtController:
replicas: 1
nodeSelector: {}
tolerations: []
affinity: {}
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

podAnnotations: {}
image:
repository: smartxworks/virt-controller

virtDaemon:
nodeSelector: {}
tolerations: []
affinity: {}
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

podAnnotations: {}
image:
repository: smartxworks/virt-daemon

clusterDomain: cluster.local

image:
registry: ""
repository: ""
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "v0.10.0"
digest: ""

nameOverride: ""
fullnameOverride: ""
6 changes: 0 additions & 6 deletions deploy/kustomization.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions deploy/namespace.yaml

This file was deleted.

Loading