diff --git a/lfc-scheduler/Makefile b/lfc-scheduler/Makefile index ed68152e67..47965bf730 100644 --- a/lfc-scheduler/Makefile +++ b/lfc-scheduler/Makefile @@ -35,6 +35,19 @@ RELEASE_CONTROLLER_IMAGE:=controller:$(RELEASE_VERSION) # v20200521-v0.18.800 - automated build for a tag VERSION=$(shell echo $(RELEASE_VERSION) | awk -F - '{print $$2}') + +## Location to install dependencies to +LOCALBIN ?= $(shell pwd)/bin +$(LOCALBIN): + mkdir -p $(LOCALBIN) + +## Tool Versions +KUSTOMIZE_VERSION ?= v3.8.7 + +## Tool Binaries +KUSTOMIZE ?= $(LOCALBIN)/kustomize +KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" + .PHONY: all all: build @@ -84,6 +97,16 @@ vet: ## Run go vet against code. test: fmt vet ## Run tests. go test ./... -coverprofile cover.out +.PHONY: kustomize +kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. +$(KUSTOMIZE): $(LOCALBIN) + test -s $(LOCALBIN)/kustomize || { curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); } + +.PHONY: release-manifests +release-manifests: kustomize + cd manifests/install && $(KUSTOMIZE) edit set image klfc-scheduler=$(RELEASE_REGISTRY)/$(RELEASE_IMAGE) + $(KUSTOMIZE) build manifests/install > config/rendered/release.yaml + .PHONY: local-image local-image: clean docker build --build-arg ARCH="amd64" --build-arg RELEASE_VERSION="$(RELEASE_VERSION)" -t $(LOCAL_REGISTRY)/$(LOCAL_IMAGE) . diff --git a/lfc-scheduler/config/rendered/.gitkeep b/lfc-scheduler/config/rendered/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lfc-scheduler/manifests/install/charts/keptn-scheduler/templates/deployment.yaml b/lfc-scheduler/manifests/install/base/deployment.yaml similarity index 81% rename from lfc-scheduler/manifests/install/charts/keptn-scheduler/templates/deployment.yaml rename to lfc-scheduler/manifests/install/base/deployment.yaml index 288da88d5a..74826b8e73 100644 --- a/lfc-scheduler/manifests/install/charts/keptn-scheduler/templates/deployment.yaml +++ b/lfc-scheduler/manifests/install/base/deployment.yaml @@ -3,13 +3,13 @@ kind: Deployment metadata: labels: component: scheduler - name: {{ .Values.scheduler.name }} - namespace: {{ .Values.scheduler.namespace }} + name: keptn-scheduler + namespace: keptn-lifecycle-controller-system spec: selector: matchLabels: component: scheduler - replicas: {{ .Values.scheduler.replicaCount }} + replicas: 1 template: metadata: labels: @@ -20,7 +20,7 @@ spec: - command: - /bin/kube-scheduler - --config=/etc/kubernetes/scheduler-config.yaml - image: {{ .Values.scheduler.image }} + image: klfc-scheduler:latest livenessProbe: httpGet: path: /healthz @@ -35,7 +35,7 @@ spec: scheme: HTTPS resources: requests: - cpu: '0.1' + cpu: '100m' securityContext: privileged: false volumeMounts: @@ -47,4 +47,4 @@ spec: volumes: - name: scheduler-config configMap: - name: scheduler-config \ No newline at end of file + name: scheduler-config diff --git a/lfc-scheduler/manifests/install/charts/keptn-scheduler/templates/rbac.yaml b/lfc-scheduler/manifests/install/base/rbac.yaml similarity index 94% rename from lfc-scheduler/manifests/install/charts/keptn-scheduler/templates/rbac.yaml rename to lfc-scheduler/manifests/install/base/rbac.yaml index db9981284a..7f5a098004 100644 --- a/lfc-scheduler/manifests/install/charts/keptn-scheduler/templates/rbac.yaml +++ b/lfc-scheduler/manifests/install/base/rbac.yaml @@ -80,8 +80,8 @@ roleRef: name: keptn-scheduler subjects: - kind: ServiceAccount - name: {{ .Values.scheduler.name }} - namespace: {{ .Values.scheduler.namespace }} + name: keptn-scheduler + namespace: keptn-lifecycle-controller-system --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding @@ -94,5 +94,5 @@ roleRef: name: extension-apiserver-authentication-reader subjects: - kind: ServiceAccount - name: {{ .Values.scheduler.name }} - namespace: {{ .Values.scheduler.namespace }} + name: keptn-scheduler + namespace: keptn-lifecycle-controller-system diff --git a/lfc-scheduler/manifests/install/base/scheduler-config.yaml b/lfc-scheduler/manifests/install/base/scheduler-config.yaml new file mode 100644 index 0000000000..61b9269d5c --- /dev/null +++ b/lfc-scheduler/manifests/install/base/scheduler-config.yaml @@ -0,0 +1,13 @@ +apiVersion: kubescheduler.config.k8s.io/v1beta3 +kind: KubeSchedulerConfiguration +leaderElection: + leaderElect: false +profiles: + # Compose all plugins in one profile + - schedulerName: keptn-scheduler + plugins: + multiPoint: + enabled: + - name: "KLCPermit" + disabled: [] + pluginConfig: {} diff --git a/lfc-scheduler/manifests/install/base/serviceaccount.yaml b/lfc-scheduler/manifests/install/base/serviceaccount.yaml new file mode 100644 index 0000000000..887aa5ecdf --- /dev/null +++ b/lfc-scheduler/manifests/install/base/serviceaccount.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: keptn-scheduler + namespace: keptn-lifecycle-controller-system + diff --git a/lfc-scheduler/manifests/install/charts/keptn-scheduler/.helmignore b/lfc-scheduler/manifests/install/charts/keptn-scheduler/.helmignore deleted file mode 100644 index 0e8a0eb36f..0000000000 --- a/lfc-scheduler/manifests/install/charts/keptn-scheduler/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ diff --git a/lfc-scheduler/manifests/install/charts/keptn-scheduler/Chart.yaml b/lfc-scheduler/manifests/install/charts/keptn-scheduler/Chart.yaml deleted file mode 100644 index 841062bd01..0000000000 --- a/lfc-scheduler/manifests/install/charts/keptn-scheduler/Chart.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: v2 -name: keptn-scheduler -description: deploy scheduler plugin as a second scheduler in cluster - -# 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.23.10 - -# 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. -appVersion: 0.23.10 - diff --git a/lfc-scheduler/manifests/install/charts/keptn-scheduler/README.md b/lfc-scheduler/manifests/install/charts/keptn-scheduler/README.md deleted file mode 100644 index a74c5a7975..0000000000 --- a/lfc-scheduler/manifests/install/charts/keptn-scheduler/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# Scheduler-plugins as a second scheduler in cluster - -## Installation - -Quick start instructions for the setup and configuration of as-a-second-scheduler using Helm. - -### Prerequisites - -- [Helm](https://helm.sh/docs/intro/quickstart/#install-helm) - -### Installing the chart - -#### Install chart using Helm v3.0+ - -```bash -$ git clone git@github.com::keptn-sandbox/lifecycle-controller.git -$ cd lifecycle-controller/lfc-scheduler/manifests/install/charts -$ helm install keptn-scheduler keptn-scheduler/ -``` - -#### Verify that scheduler and plugin-controller pod are running properly. - -```bash -$ kubectl get deploy -n scheduler-plugins -NAME READY UP-TO-DATE AVAILABLE AGE -keptn-scheduler 1/1 1 1 7s -``` - -### Configuration - -The following table lists the configurable parameters of the scheduler chart and their default values. - -| Parameter | Description | Default | -| --------------------------------------- |-------------------------------|---------------------------------------| -| `scheduler.name` | Scheduler name | `keptn-scheduler` | -| `scheduler.image` | Scheduler image | `` | -| `scheduler.namespace` | Scheduler namespace | `keptn-lifecycle-controller-system` | -| `scheduler.replicaCount` | Scheduler replicaCount | `1` | -| `plugins.enabled` | Plugins enabled by default | `["KLCPermit"]` | -| `plugins.enabled` | Plugins disabled by default | `[""]` | - diff --git a/lfc-scheduler/manifests/install/charts/keptn-scheduler/templates/_helpers.tpl b/lfc-scheduler/manifests/install/charts/keptn-scheduler/templates/_helpers.tpl deleted file mode 100644 index 0f8a475ae4..0000000000 --- a/lfc-scheduler/manifests/install/charts/keptn-scheduler/templates/_helpers.tpl +++ /dev/null @@ -1,52 +0,0 @@ -{{/* -Expand the name of the chart. -*/}} -{{- define "scheduler-plugins-as-a-second-scheduler.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 "scheduler-plugins-as-a-second-scheduler.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 "scheduler-plugins-as-a-second-scheduler.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "scheduler-plugins-as-a-second-scheduler.labels" -}} -helm.sh/chart: {{ include "scheduler-plugins-as-a-second-scheduler.chart" . }} -{{ include "scheduler-plugins-as-a-second-scheduler.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "scheduler-plugins-as-a-second-scheduler.selectorLabels" -}} -app.kubernetes.io/name: {{ include "scheduler-plugins-as-a-second-scheduler.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - diff --git a/lfc-scheduler/manifests/install/charts/keptn-scheduler/templates/configmap.yaml b/lfc-scheduler/manifests/install/charts/keptn-scheduler/templates/configmap.yaml deleted file mode 100644 index 07036a13a1..0000000000 --- a/lfc-scheduler/manifests/install/charts/keptn-scheduler/templates/configmap.yaml +++ /dev/null @@ -1,32 +0,0 @@ -{{- if .Values.plugins.enabled }} -apiVersion: v1 -kind: ConfigMap -metadata: - name: scheduler-config - namespace: {{ .Values.scheduler.namespace }} -data: - scheduler-config.yaml: | - apiVersion: kubescheduler.config.k8s.io/v1beta3 - kind: KubeSchedulerConfiguration - leaderElection: - leaderElect: {{ .Values.scheduler.leaderElect }} - profiles: - # Compose all plugins in one profile - - schedulerName: {{ .Values.scheduler.name }} - plugins: - multiPoint: - enabled: - {{- range $.Values.plugins.enabled }} - - name: {{ title . }} - {{- end }} - disabled: - {{- range $.Values.plugins.disabled }} - - name: {{ title . }} - {{- end }} - {{- if $.Values.pluginConfig }} - pluginConfig: {{ toYaml $.Values.pluginConfig | nindent 6 }} - {{- end }} - - {{- /* TODO: wire CRD installation with enabled plugins. */}} -{{- end }} - diff --git a/lfc-scheduler/manifests/install/charts/keptn-scheduler/templates/serviceaccount.yaml b/lfc-scheduler/manifests/install/charts/keptn-scheduler/templates/serviceaccount.yaml deleted file mode 100644 index 6c6678bd61..0000000000 --- a/lfc-scheduler/manifests/install/charts/keptn-scheduler/templates/serviceaccount.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ .Values.scheduler.name }} - namespace: {{ .Values.scheduler.namespace }} - - diff --git a/lfc-scheduler/manifests/install/charts/keptn-scheduler/values.yaml b/lfc-scheduler/manifests/install/charts/keptn-scheduler/values.yaml deleted file mode 100644 index a87d4f1f80..0000000000 --- a/lfc-scheduler/manifests/install/charts/keptn-scheduler/values.yaml +++ /dev/null @@ -1,37 +0,0 @@ - -# Default values for scheduler-plugins-as-a-second-scheduler. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -scheduler: - name: keptn-scheduler - image: docker.io/odubajdt/kube-scheduler:202209261664175687-v0.24.3 #we still do not have a register setup, edit the Makefile to point to your own register, run 'make push-release-images' copy the resulting image here - namespace: keptn-lifecycle-controller-system - replicaCount: 1 - leaderElect: false - -#controller: -# name: scheduler-plugins-controller -# image: k8s.gcr.io/scheduler-plugins/controller:v0.23.10 -# namespace: keptn-scheduler -# replicaCount: 1 - -# LoadVariationRiskBalancing and TargetLoadPacking are not enabled by default -# as they need extra RBAC privileges on metrics.k8s.io. - -plugins: - enabled: ["KLCPermit"] - disabled: [] # only in-tree plugins need to be defined here - -# Customize the enabled plugins' config. -# Refer to the "pluginConfig" section of manifests//scheduler-config.yaml. -# For example, for Coscheduling plugin, you want to customize the permit waiting timeout to 10 seconds: -#pluginConfig: -#- name: Coscheduling -# args: -# permitWaitingTimeSeconds: 10 # default is 60 -# Or, customize the other plugins -# - name: NodeResourceTopologyMatch -# args: -# scoringStrategy: -# type: MostAllocated # default is LeastAllocated diff --git a/lfc-scheduler/manifests/install/kustomization.yaml b/lfc-scheduler/manifests/install/kustomization.yaml new file mode 100644 index 0000000000..cd8709c249 --- /dev/null +++ b/lfc-scheduler/manifests/install/kustomization.yaml @@ -0,0 +1,19 @@ +resources: + - base/deployment.yaml + - base/rbac.yaml + - base/serviceaccount.yaml + +generatorOptions: + disableNameSuffixHash: true + +configMapGenerator: + - files: + - base/scheduler-config.yaml + name: scheduler-config + +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +images: + - name: klfc-scheduler + newName: ghcr.io/keptn-sandbox/lfc-scheduler + newTag: latest