Skip to content

Commit

Permalink
Merge pull request #19 from SUSE/develop
Browse files Browse the repository at this point in the history
Add Portworx BBQ Helm chart & SUSE Linux scripts (#18)
  • Loading branch information
devpro authored Oct 2, 2024
2 parents 0344456 + ff6c452 commit ef52858
Show file tree
Hide file tree
Showing 18 changed files with 333 additions and 7 deletions.
2 changes: 1 addition & 1 deletion charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ helm template <releasename> . -f values.yaml -f values_mine.yaml --namespace dem
# installs a chart from local source
helm upgrade --install <releasename> . -f values.yaml \
# --debug > output.yaml \
--create-namespace --namespace nfs-ganesha
--create-namespace --namespace demo
```
2 changes: 1 addition & 1 deletion charts/nfs-ganesha/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: nfs-ganesha
description: Helm chart for managing NFS-Ganesha
type: application
version: "0.1.0"
version: "0.1.1"
appVersion: "1.0.0"
dependencies: []
home: https://github.com/SUSE/lab-setup/tree/main/charts/nfs-ganesha
Expand Down
6 changes: 6 additions & 0 deletions charts/portworx-bbq/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: mongodb
repository: https://charts.bitnami.com/bitnami
version: 15.6.25
digest: sha256:833d69d2d3009fa6e91af738d0b0317ac50454ca7458c547d7281a3d150decd1
generated: "2024-10-02T17:33:33.71790146+02:00"
18 changes: 18 additions & 0 deletions charts/portworx-bbq/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v2
name: portworx-bbq
description: Helm chart for Portworx BBQ demo application
type: application
version: 0.1.0
appVersion: "1.0.0"
home: https://github.com/SUSE/lab-setup/tree/main/charts/portworx-bbq
dependencies:
- name: mongodb
version: 15.6.25 # app version: 7.0.14
repository: https://charts.bitnami.com/bitnami
alias: mongodb
condition: mongodb.enabled
maintainers:
- name: devpro
email: [email protected]
- name: ccrow42
email: [email protected]
51 changes: 51 additions & 0 deletions charts/portworx-bbq/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Portworx BBQ Helm Chart

This chart will install the **Portworx BBQ (pxbbq)** demo application in a Kubernetes cluster ([source](https://github.com/theITHollow/shanksbbq)).

You can learn more about it by looking at [Azure/kubernetes-hackfest](https://github.com/Azure/kubernetes-hackfest/blob/master/labs/storage/portworx/README.md) repository.

## Quick start

Install the app with default settings:

```bash
# adds the repo
helm repo add suse-lab-setup https://opensource.suse.com/lab-setup
helm repo update

# installs the chart
helm upgrade --install portworx-bbq suse-lab-setup/portworx-bbq --namespace pxbbq --create-namespace
```

Look at [values.yaml](values.yaml) for the configuration.

Clean-up:

```bash
helm delete portworx-bbq --namespace pxbbq
kubectl delete ns pxbbq
```

## Chart dependencies

### MongoDB chart

Add Helm repo:

```bash
helm repo add bitnami https://charts.bitnami.com/bitnami
```

Search for the latest package:

```bash
helm search repo -l mongodb --versions
```

Update `Chart.yaml`.

Update `Chart.lock`:

```bash
helm dependency update
```
Empty file.
Empty file.
63 changes: 63 additions & 0 deletions charts/portworx-bbq/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{- $applications := list .Values.front -}}
{{ range $applications }}
{{- $name := .name -}}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $name }}
labels:
app: {{ $name }}
app.kubernetes.io/name: {{ $name }}
spec:
replicas: {{ .replicaCount }}
selector:
matchLabels:
app: {{ $name }}
app.kubernetes.io/name: {{ $name }}
template:
metadata:
labels:
app: {{ $name }}
app.kubernetes.io/name: {{ $name }}
{{- if .additionalPodLabels }}
{{- toYaml .additionalPodLabels | nindent 8 }}
{{- end }}
spec:
containers:
- name: webapp
image: "{{ .image }}:{{ .tag }}"
imagePullPolicy: Always
env:
- name: MONGO_HOST
value: "{{ .db.host }}"
- name: MONGO_PORT
value: "{{ .db.port }}"
- name: MONGO_USER
value: "{{ .db.username }}"
- name: MONGO_PASS
value: "{{ .db.userpwd }}"
- name: MONGO_TLS
value: "{{ .db.tls }}"
ports:
- name: http
containerPort: {{ .containerPort }}
protocol: TCP
resources:
{{- toYaml .resources | nindent 12 }}
livenessProbe:
httpGet:
path: {{ .healthEndpoint }}
port: {{ .containerPort }}
scheme: HTTP
initialDelaySeconds: 5
periodSeconds: 15
timeoutSeconds: 5
readinessProbe:
httpGet:
path: {{ .healthEndpoint }}
port: {{ .containerPort }}
scheme: HTTP
initialDelaySeconds: 5
timeoutSeconds: 1
{{ end }}
38 changes: 38 additions & 0 deletions charts/portworx-bbq/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- $applications := list .Values.front -}}
{{ range $applications }}
{{- $name := .name -}}
{{- if $.Values.ingress.enabled -}}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $name }}
{{- with $.Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if $.Values.ingress.className }}
ingressClassName: {{ $.Values.ingress.className }}
{{- end }}
rules:
- {{- if .host }}
host: {{ .host }}
{{- end }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ $name }}
port:
number: {{ .port }}
{{- if .tls }}
tls:
- hosts:
- {{ .host | quote }}
secretName: {{ .tls.secretName }}
{{- end }}
{{- end }}
{{ end }}
22 changes: 22 additions & 0 deletions charts/portworx-bbq/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- $applications := list .Values.front -}}
{{ range $applications }}
{{- $name := .name -}}
---
apiVersion: v1
kind: Service
metadata:
name: {{ $name }}
labels:
app: {{ $name }}
app.kubernetes.io/name: {{ $name }}
spec:
type: ClusterIP
selector:
app: {{ $name }}
app.kubernetes.io/name: {{ $name }}
ports:
- name: http
port: {{ .port }}
protocol: TCP
targetPort: {{ .containerPort }}
{{ end }}
40 changes: 40 additions & 0 deletions charts/portworx-bbq/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
front:
name: pxbbq-web
image: eshanks16/pxbbq # TODO: see how to create an image using SUSE BCI
tag: v2 # v4.4 fails asking for NEO4J_URI environment variable
replicaCount: 3
containerPort: 8080
healthEndpoint: /healthz
host: ""
port: 80
tls:
secretName: "pxbbq-web-tls"
db:
host: ""
port: "27017"
username: "porxie"
userpwd: ""
tls: ""
extraEnv: []
# - name: xxx
# value: "yyyy"
additionalPodLabels: {}
resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 64Mi

ingress:
enabled: false
className: ""
annotations: {}
# cert-manager.io/cluster-issuer: letsencrypt-prod

mongodb:
enabled: false
# https://github.com/bitnami/charts/blob/main/bitnami/mongodb/values.yaml
auth: {}
# rootPassword: ""
2 changes: 1 addition & 1 deletion charts/rancher-cluster-templates/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: rancher-cluster-templates
description: Helm chart for managing Rancher cluster templates
type: application
version: "0.1.0"
version: "0.1.1"
appVersion: "0.1.0"
annotations:
catalog.cattle.io/type: cluster-template
Expand Down
6 changes: 6 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Name | Source
-----------------------------------------------|-----------------------------------------------------------------------------
`instruqt_wait_hoststartup` | [instruqt/host.sh](instruqt/host.sh)
`k3s_copy_kubeconfig` | [k3s/cluster_lifecycle.sh](k3s/cluster_lifecycle.sh)
`k3s_create_cluster` | [k3s/cluster_lifecycle.sh](k3s/cluster_lifecycle.sh)
`k8s_create_letsencryptclusterissuer` | [kubernetes/certificate_management.sh](kubernetes/certificate_management.sh)
Expand All @@ -30,6 +31,11 @@ Name | Source
`rancher_update_password` | [rancher/user_actions.sh](rancher/user_actions.sh)
`rancher_update_serverurl` | [rancher/manager_settings.sh](rancher/manager_settings.sh)
`rancher_wait_capiready` | [rancher/manager_lifecycle.sh](rancher/manager_lifecycle.sh)
`suselinux_install_git` | [suselinux/packages.sh](suselinux/packages.sh)
`suselinux_install_helm` | [suselinux/packages.sh](suselinux/packages.sh)
`suselinux_install_kubectl` | [suselinux/packages.sh](suselinux/packages.sh)
`suselinux_install_podman` | [suselinux/packages.sh](suselinux/packages.sh)
`suselinux_register_cloudguest` | [suselinux/registration.sh](suselinux/registration.sh)

## Concrete examples

Expand Down
4 changes: 0 additions & 4 deletions scripts/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ fatal() {

verify_system() {
info 'Verify system requirements'
if [ -x /usr/bin/git ] || type git > /dev/null 2>&1; then
return
fi
fatal 'Git is not installed in the machine'
if ! command -v jq &> /dev/null; then
fatal 'jq is not installed in the machine'
fi
Expand Down
15 changes: 15 additions & 0 deletions scripts/instruqt/host.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# Collection of functions to work with hosts in Instruqt

#######################################
# Wait for host startup
# Examples:
# instruqt_wait_hoststartup
#######################################
instruqt_wait_hoststartup() {
# waits for Instruqt host bootstrap to finish
until [ -f /opt/instruqt/bootstrap/host-bootstrap-completed ]
do
sleep 1
done
}
2 changes: 2 additions & 0 deletions scripts/rancher/cluster_actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ rancher_create_customcluster() {
local name=$1
local version=$2

rancher_wait_capiready

echo "Creating downstream cluster in Rancher..."
cat <<EOF | kubectl apply -f -
apiVersion: provisioning.cattle.io/v1
Expand Down
56 changes: 56 additions & 0 deletions scripts/suselinux/packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
# Collection of functions to manage packages on SUSE Linux distributions

#######################################
# Install kubectl (Kubernetes CLI) on SUSE Linux
# Arguments:
# kubernetesVersion
# Examples:
# suselinux_install_kubectl 'v1.30'
#######################################
suselinux_install_kubectl() {
local kubernetesVersion=$1

# adds keys for new packages to be installed
cat <<EOF | sudo tee /etc/zypp/repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/$kubernetesVersion/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/$kubernetesVersion/rpm/repodata/repomd.xml.key
EOF

# refreshes packages and import new keys
zypper --gpg-auto-import-keys refresh

# installs Kubernetes CLI
zypper install -y kubectl
}

#######################################
# Install kubectl (Kubernetes CLI) on SUSE Linux
# Examples:
# suselinux_install_kubectl
#######################################
suselinux_install_helm() {
zypper install -y helm
}

#######################################
# Install git on SUSE Linux
# Examples:
# suselinux_install_kubectl
#######################################
suselinux_install_git() {
zypper install -y git
}

#######################################
# Install Podman on SUSE Linux
# Examples:
# suselinux_install_kubectl
#######################################
suselinux_install_podman() {
zypper install -y podman
}
13 changes: 13 additions & 0 deletions scripts/suselinux/registration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# Collection of functions to register on SUSE Linux distributions

#######################################
# Register Cloud guest on SUSE Linux
# Examples:
# suselinux_register_cloudguest
#######################################
suselinux_register_cloudguest() {
registercloudguest --force-new
# temporary workaround (the file is generated registercloudguest and prevents further container image pulling)
rm ~/.docker/config.json
}

0 comments on commit ef52858

Please sign in to comment.