generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
60 changed files
with
2,475 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.helmignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: v2 | ||
description: KWOK Operator | ||
type: application | ||
home: https://kwok.sigs.k8s.io | ||
icon: https://github.com/kubernetes-sigs/kwok/raw/main/logo/kwok.png | ||
keywords: | ||
- kubernetes | ||
- kwok | ||
- operator | ||
sources: | ||
- https://github.com/kubernetes-sigs/kwok | ||
name: operator | ||
maintainers: | ||
- name: wzshiming | ||
email: [email protected] | ||
appVersion: v0.6.0 | ||
version: 0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# KWOK (Kubernetes WithOut Kubelet) | ||
|
||
[KWOK](https://kwok.sigs.k8s.io/) - 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 | ||
``` | ||
|
||
Set up default metrics usage policy (optional) | ||
|
||
```shell | ||
helm upgrade --install kwok kwok/metrics-usage | ||
``` | ||
|
||
## Configuration | ||
|
||
The following table lists the configurable parameters of the kwok chart and their default values. | ||
|
||
| Key | Type | Default | Description | | ||
|-----|------|---------|-------------| | ||
| affinity | object | `{}` | | | ||
| fullnameOverride | string | `"kwok-controller"` | Override the `fullname` of the chart. | | ||
| image.pullPolicy | string | `"IfNotPresent"` | Image pull policy. | | ||
| image.repository | string | `"registry.k8s.io/kwok/kwok"` | Image repository. | | ||
| image.tag | string | `""` | Overrides the image tag whose default is {{ .Chart.AppVersion }}. | | ||
| imagePullSecrets | list | `[]` | Image pull secrets. | | ||
| nameOverride | string | `""` | Override the `name` of the chart. | | ||
| nodeSelector | object | `{}` | | | ||
| podSecurityContext | object | `{}` | | | ||
| replicas | int | `1` | The replica count for Deployment. | | ||
| resources | object | `{}` | | | ||
| securityContext | object | `{}` | | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# {{ template "chart.description" . }} | ||
|
||
{{ template "extra.usage" . }} | ||
|
||
## Configuration | ||
|
||
The following table lists the configurable parameters of the kwok chart and their default values. | ||
|
||
{{ template "chart.valuesTable" . }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../kustomize/operator/crd/bases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
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 }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
securityContext: | ||
{{- toYaml .Values.securityContext | nindent 10 }} | ||
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: kwok-operator | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- apiGroups: | ||
- kwok.x-k8s.io | ||
resources: | ||
- controllers | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- kwok.x-k8s.io | ||
resources: | ||
- controllers/status | ||
verbs: | ||
- patch | ||
- update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: kwok-operator | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: kwok-operator | ||
subjects: | ||
- kind: ServiceAccount | ||
name: kwok-operator | ||
namespace: {{ .Release.Namespace }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: kwok-operator | ||
namespace: {{ .Release.Namespace }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
image: | ||
# -- Image pull policy. | ||
pullPolicy: IfNotPresent | ||
# -- Image repository. | ||
repository: registry.k8s.io/kwok/operator | ||
# -- Overrides the image tag whose default is {{ .Chart.AppVersion }}. | ||
tag: "" | ||
|
||
# -- Image pull secrets. | ||
imagePullSecrets: [] | ||
|
||
# -- Override the `name` of the chart. | ||
nameOverride: "" | ||
|
||
# -- Override the `fullname` of the chart. | ||
fullnameOverride: "kwok-controller" | ||
|
||
podSecurityContext: {} | ||
securityContext: {} | ||
|
||
nodeSelector: {} | ||
resources: {} | ||
affinity: {} | ||
|
||
# -- The replica count for Deployment. | ||
replicas: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
Copyright 2024 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// Package main is the entry point for the kwok binary. | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/pflag" | ||
|
||
"sigs.k8s.io/kwok/pkg/config" | ||
"sigs.k8s.io/kwok/pkg/log" | ||
"sigs.k8s.io/kwok/pkg/operator/cmd" | ||
"sigs.k8s.io/kwok/pkg/utils/signals" | ||
) | ||
|
||
func main() { | ||
flagset := pflag.NewFlagSet("global", pflag.ContinueOnError) | ||
flagset.ParseErrorsWhitelist.UnknownFlags = true | ||
flagset.Usage = func() {} | ||
|
||
ctx := signals.SetupSignalContext() | ||
ctx, logger := log.InitFlags(ctx, flagset) | ||
|
||
ctx, err := config.InitFlags(ctx, flagset) | ||
if err != nil { | ||
_, _ = os.Stderr.Write([]byte(flagset.FlagUsages())) | ||
logger.Error("Init config flags", err) | ||
os.Exit(1) | ||
} | ||
|
||
command := cmd.NewCommand(ctx) | ||
command.PersistentFlags().AddFlagSet(flagset) | ||
err = command.ExecuteContext(ctx) | ||
if err != nil { | ||
logger.Error("Execute exit", err) | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.