Skip to content

Commit

Permalink
Support helm charts
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Jul 1, 2024
1 parent c969456 commit 1385b62
Show file tree
Hide file tree
Showing 32 changed files with 1,196 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/helm-lint-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Lint and Test Charts

on:
pull_request:
paths:
- charts/**/*
push:
paths:
- charts/**/*

jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/[email protected]
with:
version: v3.14.4

- uses: actions/setup-python@v5
with:
python-version: '3.x'
check-latest: true

- name: Set up chart-testing
uses: helm/[email protected]

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --target-branch ${{ github.event.repository.default_branch }}

- name: Create kind cluster
if: steps.list-changed.outputs.changed == 'true'
uses: helm/[email protected]

- name: Run chart-testing (install)
if: steps.list-changed.outputs.changed == 'true'
run: ct install --target-branch ${{ github.event.repository.default_branch }}

linter-artifacthub:
runs-on: ubuntu-latest
container:
image: artifacthub/ah
options: --user root
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run ah lint
working-directory: ./charts/
run: ah lint
40 changes: 40 additions & 0 deletions .github/workflows/helm-releases.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Releases Charts

on:
push:
branches:
- release-*
- main
paths:
- charts/kwok/Chart.yaml
- charts/stage-fast/Chart.yaml

env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
releases:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Helm
uses: azure/setup-helm@v4

- name: Upload blob and build index
run: ./hack/releases-helm-charts.sh

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
add-paths: |
site/static/charts/index.yaml
token: ${{ env.GH_TOKEN }}
branch: dependabot/bump-chart-releases
commit-message: Release charts
delete-branch: true
title: 'Release charts'
body: |
Release charts
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/bin/
/artifacts/
/workdir/
*.tgz

# used for the code generators only
/vendor/
Expand Down
1 change: 1 addition & 0 deletions charts/kwok/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.helmignore
16 changes: 16 additions & 0 deletions charts/kwok/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v2
description: KWOK (Kubernetes WithOut Kubelet)
type: application
home: https://kwok.sigs.k8s.io
icon: https://github.com/kubernetes-sigs/kwok/raw/main/logo/kwok.png
keywords:
- kubernetes
- kwok
sources:
- https://github.com/kubernetes-sigs/kwok
name: kwok
maintainers:
- name: wzshiming
email: [email protected]
appVersion: v0.5.2
version: 0.0.1
38 changes: 38 additions & 0 deletions charts/kwok/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# KWOK (Kubernetes WithOut Kubelet)

[KWOK](https://github.com/kubernetes-sigs/kwok/) - Simulates thousands of Nodes and Clusters.

## Installing the Chart

Before you can install the chart you will need to add the `kwok` repo to [Helm](https://helm.sh/).

```shell
helm repo add kwok https://kwok.sigs.k8s.io/charts/
```

After you've installed the repo you can install the chart.

```shell
helm upgrade --namespace kube-system --install kwok kwok/kwok
```

Set up default stage policy (required)
> NOTE: This configures the pod/node emulation behavior, if not it will do nothing.
```shell
helm upgrade --install kwok kwok/stage-fast
```

## Configuration

The following table lists the configurable parameters of the kwok chart and their default values.

| Parameter | Description | Default |
|--------------------|------------------------------------------------------------------------------|-----------------------------|
| `image.repository` | Image repository. | `registry.k8s.io/kwok/kwok` |
| `image.tag` | Image tag, will override the default tag derived from the chart app version. | `[chart appVersion]` |
| `image.pullPolicy` | Image pull policy. | `IfNotPresent` |
| `imagePullSecrets` | Image pull secrets. | `[]` |
| `nameOverride` | Override the `name` of the chart. | `""` |
| `fullnameOverride` | Override the `fullname` of the chart. | `""` |
| `replicas` | The replica count for Deployment. | `1` |
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 }}
105 changes: 105 additions & 0 deletions charts/kwok/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "kwok.fullname" . }}
labels:
{{- include "kwok.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicas }}
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" . }}
{{- with .Values.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
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 10 }}
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 10 }}
{{- 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 1385b62

Please sign in to comment.