Skip to content

Commit

Permalink
Support helm charts
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Jun 26, 2024
1 parent 27dc070 commit 776439a
Show file tree
Hide file tree
Showing 29 changed files with 1,079 additions and 4 deletions.
16 changes: 16 additions & 0 deletions .dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ dependencies:
- path: hack/verify-dependencies-version.sh
match: sigs.k8s.io/zeitgeist@v

- name: "kwok"
version: 0.6.0
refPaths:
- path: pkg/consts/consts.go
match: "Version "
- path: charts/kwok/Chart.yaml
match: "version: "
- path: charts/kwok/Chart.yaml
match: "appVersion: "
- path: charts/kwok/values.yaml
match: " tag: "
- path: charts/stage-fast/Chart.yaml
match: "version: "
- path: charts/stage-fast/Chart.yaml
match: "appVersion: "

- name: "golang"
version: 1.22.3
refPaths:
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,14 @@ jobs:
run: |
REF=${{ github.ref }}
GIT_TAG="${REF##*/}" make cross-cluster-image
- name: Install Helm
uses: azure/setup-helm@v4
- name: Release helm chart
uses: helm/[email protected]
with:
packages_with_index: true
mark_as_latest: true
pages_branch: "gh-pages"
env:
CR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 changes: 23 additions & 0 deletions charts/kwok/.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/
21 changes: 21 additions & 0 deletions charts/kwok/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
name: kwok
description: A Helm chart for Kubernetes
# 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.6.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.
# It is recommended to use it with quotes.
appVersion: "0.6.0"
1 change: 1 addition & 0 deletions charts/kwok/crds
62 changes: 62 additions & 0 deletions charts/kwok/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "kwok.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 "kwok.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 "kwok.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "kwok.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "kwok.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
103 changes: 103 additions & 0 deletions charts/kwok/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "kwok.fullname" . }}
labels:
{{- include "kwok.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "kwok.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "kwok.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "kwok.fullname" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
restartPolicy: Always
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
args:
- --manage-all-nodes=false
- --manage-nodes-with-annotation-selector=kwok.x-k8s.io/node=fake
- --manage-nodes-with-label-selector=
- --manage-single-node=
- --disregard-status-with-annotation-selector=kwok.x-k8s.io/status=custom
- --disregard-status-with-label-selector=
- --node-ip=$(POD_IP)
- --node-port=10247
- --cidr=10.0.0.1/24
- --node-lease-duration-seconds=40
- --enable-crds=Stage
- --enable-crds=Metric
- --enable-crds=Attach
- --enable-crds=ClusterAttach
- --enable-crds=Exec
- --enable-crds=ClusterExec
- --enable-crds=Logs
- --enable-crds=ClusterLogs
- --enable-crds=PortForward
- --enable-crds=ClusterPortForward
- --enable-crds=ResourceUsage
- --enable-crds=ClusterResourceUsage
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
livenessProbe:
failureThreshold: 10
httpGet:
path: /healthz
port: 10247
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 60
timeoutSeconds: 10
readinessProbe:
failureThreshold: 5
httpGet:
path: /healthz
port: 10247
scheme: HTTP
initialDelaySeconds: 2
periodSeconds: 20
timeoutSeconds: 2
startupProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: 10247
scheme: HTTP
initialDelaySeconds: 2
periodSeconds: 10
timeoutSeconds: 2
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
Loading

0 comments on commit 776439a

Please sign in to comment.