Skip to content

Commit

Permalink
Add kwokctl component api
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Nov 27, 2023
1 parent 63d0e9f commit abc2c36
Show file tree
Hide file tree
Showing 66 changed files with 3,117 additions and 2,949 deletions.
55 changes: 55 additions & 0 deletions kustomize/kwokctl/component/dashboard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apiVersion: config.kwok.x-k8s.io/v1alpha1
kind: KwokctlComponent
metadata:
name: dashboard
parameters:
image: ""
binary: ""
version: "2.7.0"
bindAddress: "0.0.0.0"
port: 8000
template: |-
{{ $version :=
( or
( env "KWOK_DASHBOARD_VERSION" )
.version
)
}}
{{ $image :=
( or
.image
( env "KWOK_DASHBOARD_IMAGE" )
( join
""
( list
( or
( env "KWOK_DASHBOARD_IMAGE_PREFIX" )
"docker.io/kubernetesui"
)
"/dashboard:v"
$version
)
)
)
}}
image: {{ $image }}
binary: {{ .binary }}
links:
- kube-apiserver
ports:
- name: http
port: {{ .port }}
hostPort: {{ .port }}
protocol: TCP
args:
- --insecure-bind-address={{ .bindAddress }}
- --insecure-port={{ .port }}
- --bind-address=127.0.0.1
- --port=0
- --enable-insecure-login
- --enable-skip-login
- --disable-settings-authorizer
- --metrics-provider=none
- --system-banner=Welcome to {{ ClusterName }}
- --kubeconfig={{ Kubeconfig }}
44 changes: 44 additions & 0 deletions kustomize/kwokctl/component/embed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright 2023 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 component contains default component for kwokctl.
package component

import (
_ "embed"
)

var (
// DefaultDashboard is the default dashboard component.
//go:embed dashboard.yaml
DefaultDashboard string

// DefaultPrometheus is the default prometheus component.
//go:embed prometheus.yaml
DefaultPrometheus string

// DefaultKwokController is the default kwok controller component.
//go:embed kwok-controller.yaml
DefaultKwokController string

// DefaultKubeControllerManager is the default kube-controller-manager component.
//go:embed kube-controller-manager.yaml
DefaultKubeControllerManager string

// DefaultKubeScheduler is the default kube-scheduler component.
//go:embed kube-scheduler.yaml
DefaultKubeScheduler string
)
65 changes: 65 additions & 0 deletions kustomize/kwokctl/component/kube-controller-manager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
apiVersion: config.kwok.x-k8s.io/v1alpha1
kind: KwokctlComponent
metadata:
name: kube-controller-manager
parameters:
image: ""
binary: ""
bindAddress: "0.0.0.0"
port: 10257
expose: false
template: |-
{{ $image :=
( or
.image
Config.Options.KubeControllerManagerImage
)
}}
{{ $binary :=
( or
.binary
Config.Options.KubeControllerManagerBinary
)
}}
image: {{ $image }}
binary: {{ $binary }}
links:
- kube-apiserver
workdir: {{ Workdir }}
{{ if .expose }}
ports:
- name: http
port: {{ .port }}
hostPort: {{ .port }}
protocol: TCP
{{ end }}
command:
- kube-controller-manager
args:
{{ with Config.Options.KubeFeatureGates }}
- --feature-gates={{ . }}
{{ end }}
{{ with Config.Options.KubeControllerManagerNodeMonitorPeriodMilliseconds }}
- --node-monitor-period={{ . }}ms
{{ end }}
{{ with Config.Options.KubeControllerManagerNodeMonitorGracePeriodMilliseconds }}
- --node-monitor-grace-period={{ . }}ms
{{ end }}
- --kubeconfig={{ Kubeconfig }}
- --bind-address={{ .bindAddress }}
- --secure-port={{ .port }}
- --root-ca-file={{ PkiDir }}/ca.crt
- --service-account-private-key-file={{ PkiDir }}/admin.key
{{ with Config.Options.DisableQPSLimits }}
- --kube-api-qps=5000
- --kube-api-burst=1000
{{ end }}
- --authorization-always-allow-paths=/healthz,/readyz,/livez,/metrics
metric:
scheme: https
host: {{ Address }}:{{ .port }}
path: /metrics
certPath: {{ PkiDir }}/admin.crt
keyPath: {{ PkiDir }}/admin.key
insecureSkipVerify: true
57 changes: 57 additions & 0 deletions kustomize/kwokctl/component/kube-scheduler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apiVersion: config.kwok.x-k8s.io/v1alpha1
kind: KwokctlComponent
metadata:
name: kube-scheduler
parameters:
image: ""
binary: ""
bindAddress: "0.0.0.0"
port: 10259
expose: false
template: |-
{{ $image :=
( or
.image
Config.Options.KubeSchedulerImage
)
}}
{{ $binary :=
( or
.binary
Config.Options.KubeSchedulerBinary
)
}}
image: {{ $image }}
binary: {{ $binary }}
links:
- kube-apiserver
workdir: {{ Workdir }}
{{ if .expose }}
ports:
- name: http
port: {{ .port }}
hostPort: {{ .port }}
protocol: TCP
{{ end }}
command:
- kube-scheduler
args:
{{ with Config.Options.KubeFeatureGates }}
- --feature-gates=.
{{ end }}
- --kubeconfig={{ Kubeconfig }}
- --bind-address={{ .bindAddress }}
- --secure-port={{ .port }}
{{ with Config.Options.DisableQPSLimits }}
- --kube-api-qps=5000
- --kube-api-burst=1000
{{ end }}
- --authorization-always-allow-paths=/healthz,/readyz,/livez,/metrics
metric:
scheme: https
host: {{ Address }}:{{ .port }}
path: /metrics
certPath: {{ PkiDir }}/admin.crt
keyPath: {{ PkiDir }}/admin.key
insecureSkipVerify: true
8 changes: 8 additions & 0 deletions kustomize/kwokctl/component/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- dashboard.yaml
- prometheus.yaml
- kwok-controller.yaml
- kube-controller-manager.yaml
- kube-scheduler.yaml
87 changes: 87 additions & 0 deletions kustomize/kwokctl/component/kwok-controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
apiVersion: config.kwok.x-k8s.io/v1alpha1
kind: KwokctlComponent
metadata:
name: kwok-controller
parameters:
image: ""
binary: ""
version: "0.4.0"
bindAddress: "0.0.0.0"
port: 10247
expose: false
template: |-
{{ $version :=
( or
( env "KWOK_CONTROLLER_VERSION" )
.version
)
}}
{{ $image :=
( or
.image
( env "KWOK_CONTROLLER_IMAGE" )
( printf
"%s/kwok:v%s"
( or
( env "KWOK_CONTROLLER_IMAGE_PREFIX" )
"registry.k8s.io/kwok"
)
$version
)
)
}}
{{ $binary :=
( or
.binary
( env "KWOK_CONTROLLER_BINARY" )
( printf
"%s/kwok-%s-%s"
( or
( env "KWOK_CONTROLLER_BINARY_PREFIX" )
( printf
"https://github.com/kubernetes-sigs/kwok/releases/download/v%s/"
$version
)
)
( goos )
( goarch )
)
)
}}
image: {{ $image }}
binary: {{ $binary }}
links:
- kube-apiserver
workdir: {{ Workdir }}
{{ if .expose }}
ports:
- name: http
port: {{ .port }}
hostPort: {{ .port }}
protocol: TCP
{{ end }}
args:
{{ if eq Mode "cluster" }}
- --manage-all-nodes=false
- --manage-nodes-with-annotation-selector=kwok.x-k8s.io/node=fake
{{ else }}
- --manage-all-nodes=true
{{ end }}
- --kubeconfig={{ Kubeconfig }}
- --config=~/.kwok/kwok.yaml
- --tls-cert-file={{ PkiDir }}/admin.crt
- --tls-private-key-file={{ PkiDir }}/admin.key
{{ if eq ( Mode ) "cluster" }}
- --node-ip=$(POD_IP)
- --node-name=kwok-controller.kube-system.svc
{{ else }}
- --node-name={{ Address }}
{{ end }}
- --node-port={{ .port }}
- --server-address=0.0.0.0:{{ .port }}
- --node-lease-duration-seconds={{ Config.Options.NodeLeaseDurationSeconds }}
metric:
scheme: http
host: {{ Address }}:{{ .port }}
path: /metrics
Loading

0 comments on commit abc2c36

Please sign in to comment.