Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm #110

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
build
k8s-operator-hpcr.exe
k8s-operator-hpcr
.env
samples/apikey.yaml
main.exe
Expand Down
50 changes: 2 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,52 +18,6 @@ To get started, see [how to setup the controller in your cluster](#installing-th
- all disks for the onprem case are created on the same storage pool
- IBM Hyper Protect Virtual Servers v1 and IBM Cloud® Hyper Protect Virtual Servers v1 are not supported.

## Installing the Controller
## Installation & Deployment

You need a Kubernetes cluster with Internet connectivity.

### 1. Install [Metacontroller](https://metacontroller.github.io/metacontroller/guide/install.html):

```bash
kubectl apply -k https://github.com/metacontroller/metacontroller/manifests/production
```

### 2. Install the Hyper Protect Virtual Servers Kubernetes Operator

```bash
kubectl apply -k https://github.com/ibm-hyper-protect/k8s-operator-hpcr/manifests
```

### 3. Verify your installation by checking for the existence of the custom resources

```bash
kubectl get crds

NAME CREATED AT
compositecontrollers.metacontroller.k8s.io 2023-03-15T21:32:11Z
controllerrevisions.metacontroller.k8s.io 2023-03-15T21:32:11Z
decoratorcontrollers.metacontroller.k8s.io 2023-03-15T21:32:11Z
onprem-hpcrs.hpse.ibm.com 2023-03-17T12:44:30Z
vpc-hpcrs.hpse.ibm.com 2023-03-17T12:44:30Z
```

```bash
kubectl get compositecontrollers

NAME AGE
k8s-operator-hpcr-onprem 5m37s
k8s-operator-hpcr-vpc 5m37s
```

```bash
kubectl get deployments

NAME READY UP-TO-DATE AVAILABLE AGE
k8s-operator-hpcr 1/1 1 1 6m35s
```

### Show Logs

```bash
kubectl logs -l app=k8s-operator-hpcr
```
Follow the instructions in the [deploy](https://github.com/ibm-hyper-protect/k8s-operator-hpcr/deploy) directory to install the operator on your cluster.
24 changes: 24 additions & 0 deletions deploy/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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/
.helmignore
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
7 changes: 7 additions & 0 deletions deploy/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.PHONY: manifests
manifests:
helm template k8s-operator-hpcr-deployment charts/k8s-operator-hpcr -f helm-values.yaml > manifests/manifests.yaml

.PHONY: kustomize-install
kustomize-install:
kubectl apply -k manifests
73 changes: 73 additions & 0 deletions deploy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Installing the Controller

You need a Kubernetes cluster with Internet connectivity.

## 1. Install [Metacontroller](https://metacontroller.github.io/metacontroller/guide/install.html):

```bash
kubectl apply -k https://github.com/metacontroller/metacontroller/manifests/production
```

## 2. Install the Hyper Protect Virtual Servers Kubernetes Operator
The operator is installed via its helm chart.
Add the operator's helm chart to your local helm repository list as `k8s-operator-hpcr`.
``` bash
helm repo add k8s-operator-hpcr https://charts.k8s-operator-hpcr.io
```
Install the chart with the release name `k8s-operator-hpcr`:
``` bash
helm install k8s-operator-hpcr k8s-operator-hpcr/k8s-operator-hpcr
```

### Generate my own Manifest files
The static deployment manifests would be generated from the helm chart and bundled as part of a release on github.
You can also generate your own static deployment manifests on your local workstation, using helm and make.
The default deployment values can be overwrtitten by customizing the `helm-values.yaml` file.
```bash
make manifests
```
Then install the operator on your cluster via kubectl and kustomize. Be sure to have created the namespace for the operator's namespace on your cluster before apply the manifests:
```bash
make kustomize-install
```

## 3. Verify your installation by checking for the existence of the custom resources

```bash
kubectl get crds

NAME CREATED AT
compositecontrollers.metacontroller.k8s.io 2023-03-15T21:32:11Z
controllerrevisions.metacontroller.k8s.io 2023-03-15T21:32:11Z
decoratorcontrollers.metacontroller.k8s.io 2023-03-15T21:32:11Z
onprem-hpcrs.hpse.ibm.com 2023-03-17T12:44:30Z
vpc-hpcrs.hpse.ibm.com 2023-03-17T12:44:30Z
```

```bash
kubectl get compositecontrollers

NAME AGE
k8s-operator-hpcr-onprem 5m37s
k8s-operator-hpcr-vpc 5m37s
```

```bash
kubectl get deployments -n k8s-operator-hpcr

NAME READY UP-TO-DATE AVAILABLE AGE
k8s-operator-hpcr 1/1 1 1 6m35s
```

## Show Logs

```bash
kubectl logs -l app=k8s-operator-hpcr -n k8s-operator-hpcr
```

## 4. Uninstalling the Chart
To uninstall the k8s-operator-hpcr deployment via helm:
```bash
helm uninstall k8s-operator-hpcr
```
The command removes all the Kubernetes components associated with the chart and deletes the helm release.
18 changes: 18 additions & 0 deletions deploy/charts/k8s-operator-hpcr/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v2
name: k8s-operator-hpcr
description: A Kubernetes operator for managing VPC and onprem HPCR images
type: application

version: 0.1.0
appVersion: "v0.1.0"
kubeVersion: ">= 1.19.0-0"
keywords:
- kubernetes-hpcr
- hpcr
- onprem
- vpc
home: https://github.com/ibm-hyper-protect/k8s-operator-hpcr

maintainers:
- name: Carsten Leue
email: [email protected]
19 changes: 19 additions & 0 deletions deploy/charts/k8s-operator-hpcr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Hyper Protect Virtual Servers Kubernetes Operator

## Installing the chart

To add the operator's helm chart to your local helm repository list as `k8s-hpcr-operator`.
``` bash
helm repo add k8s-hpcr-operator https://charts.k8s-hpcr-operator.io
```
Install the chart with the release name `k8s-hpcr-operator`:
``` bash
helm install k8s-hpcr-operator k8s-hpcr-operator/k8s-hpcr-operator
```

## 4. Uninstalling the Chart
To uninstall `k8s-operator-hpcr` deployment:
```bash
helm uninstall k8s-operator-hpcr
```
The command removes all the Kubernetes components associated with the chart and deletes the helm release.
File renamed without changes.
3 changes: 3 additions & 0 deletions deploy/charts/k8s-operator-hpcr/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
apiVersion: v1
entries: {}
generated: "2023-07-06T21:13:17.517976+02:00"
63 changes: 63 additions & 0 deletions deploy/charts/k8s-operator-hpcr/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "k8s-operator-hpcr.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 "k8s-operator-hpcr.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 "k8s-operator-hpcr.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "k8s-operator-hpcr.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "k8s-operator-hpcr.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
29 changes: 29 additions & 0 deletions deploy/charts/k8s-operator-hpcr/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "k8s-operator-hpcr.fullname" . }}
namespace: {{ .Values.namespace | default .Release.Namespace }}
labels:
{{- include "k8s-operator-hpcr.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "k8s-operator-hpcr.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "k8s-operator-hpcr.selectorLabels" . | nindent 8 }}
spec:
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
Loading