Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
devpro committed Sep 5, 2024
2 parents 21ad1a0 + c2c53cc commit 364c6b2
Show file tree
Hide file tree
Showing 35 changed files with 696 additions and 19 deletions.
45 changes: 39 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,59 @@ on:
push:
branches:
- main
- develop
pull_request:
branches:
- develop
schedule:
- cron: "0 2 * * 1-5"
workflow_dispatch: {}

concurrency:
group: "${{ github.ref }}-${{ github.workflow }}"
cancel-in-progress: true

jobs:
code-check:
runs-on: ubuntu-latest
steps:
- name: Checks-out the repository
- name: Check-out the repository
uses: actions/checkout@v4
- name: Lints Markdown files
with:
# gets all history for all branches and tags (mandatory for chart-testing to work, see https://github.com/helm/chart-testing/issues/186)
fetch-depth: 0
- name: Lint Markdown files
uses: DavidAnson/markdownlint-cli2-action@v16
with:
globs: '**/*.md'
# checking shell code with ShellCheck (https://github.com/koalaman/shellcheck)
- name: Installs packages
# uses https://github.com/koalaman/shellcheck
- name: Install Shellcheck
run: sudo apt install shellcheck
- name: Checks shell file code
- name: Check shell file code
run:
shellcheck -e SC2086 -e SC2034 scripts/**/*.sh
shellcheck -e SC2086 -e SC2034 -e SC2126 scripts/**/*.sh
- name: Install Helm
uses: azure/[email protected]
with:
version: v3.14.0
- name: Add dependency Helm chart repositories
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
check-latest: true
- name: Install Helm chart-testing
uses: helm/[email protected]
- name: List changed Helm charts
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --target-branch ${{ github.event.repository.default_branch }}
65 changes: 65 additions & 0 deletions .github/workflows/pkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: PKG

on:
push:
branches: [ "main" ]
workflow_dispatch:

permissions:
contents: write
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check-out the repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/[email protected]
with:
version: v3.14.0
- name: Add dependency Helm chart repositories
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
- name: Host charts repository on GitHub Pages
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Setup Go environment
uses: actions/setup-go@v5
- name: Generate index.html
run: |
go install github.com/halkeye/[email protected]
/home/runner/go/bin/helm-repo-html
- name: Setup Pages
uses: actions/configure-pages@v1
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# local downloaded chart compressed files
/**/charts/*.tgz

# local temporary files
temp*.yaml
temp.sh
/charts/temp/
values_*.y*ml
7 changes: 7 additions & 0 deletions .kube-linter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
checks:
addAllBuiltIn: true
exclude:
- "no-read-only-root-fs"
- "unset-cpu-requirements"
- "unset-memory-requirements"
ignorePaths: []
34 changes: 24 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,44 @@

[![CI](https://github.com/SUSE/lab-setup/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/SUSE/lab-setup/actions/workflows/ci.yml)

Welcome! You'll find in this repository some IT material to help setup your lab environments.
Welcome! You'll find in this repository some open-source material to setup a lab environment.

It is used internally at SUSE (the goal being to capitalize and factorize), but is open to everyone. Feel free to contribute and share feedback!

## Getting started

Wether you're looking for simple way to automate an infrastructure or running demo workload, we've got you covered!

### Bash scripting

* Download and source the files (here targetting `develop` branch but you can chose the revision you want):
Download and source the files (targetting `develop` branch):

```bash
SETUP_FOLDER=lab-setup
curl -sfL https://raw.githubusercontent.com/SUSE/lab-setup/feature/init-solution/scripts/download.sh \
| GIT_REVISION=refs/heads/develop sh -s -- -o $SETUP_FOLDER
. $SETUP_FOLDER/scripts/index.sh
curl -sfL https://raw.githubusercontent.com/SUSE/lab-setup/develop/scripts/download.sh | GIT_REVISION=refs/heads/develop sh -s -- -o temp
. temp/scripts/index.sh
```

* Try some functions:
Call a function:

```bash
# create a Kubernetes cluster (K3s distribution)
k3s_create_cluster v1.23
```

* Look at concrete examples: [Rancher installation with downstream cluster](samples/scripting/rancher_installation.sh)
Browse the [catalog of functions](scripts/README.md#shell-functions) and [concrete examples](scripts/README.md#concrete-examples).

### Helm charts

Add Helm repository:

```bash
helm repo add suse-lab-setup https://suse.github.io/lab-setup
helm repo update
```

Deploy a chart:

```bash
helm upgrade --install cow-demo suse-lab-setup/cow-demo --namespace demo
```

* Browse the [catalog of functions](scripts/README.md#shell-functions)
Browse the [catalog of Helm charts](charts/README.md).
18 changes: 18 additions & 0 deletions charts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Helm Charts

## Catalog

* [Cow Demo](cow-demo/README.md)
* [Game 2048](game-2048/README.md)
* [Let's Encrypt](letsencrypt/README.md)
* [WordPress](wordpress/README.md)

## Developer's guide

```bash
# lints a chart
helm lint .

# creates Kubernetes template file from chart (for review/comparison)
helm template myname . -f values.yaml --namespace demo > temp.yaml
```
10 changes: 10 additions & 0 deletions charts/cow-demo/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v2
name: cow-demo
description: Helm chart for Cow Demo Application
type: application
version: 0.1.0
appVersion: "2.0.0"
home: https://github.com/SUSE/lab-setup/tree/main/charts/cow-demo
maintainers:
- name: devpro
email: [email protected]
25 changes: 25 additions & 0 deletions charts/cow-demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Cow Demo Helm Chart

This chart will install the "Cow Demo" web application in a Kubernetes cluster.

## Quick start

Install the app with default settings:

```bash
# adds the repo
helm repo add devpro https://devpro.github.io/helm-charts
helm repo update

# installs the chart
helm upgrade --install cow-demo devpro/cow-demo --namespace demo --create-namespace
```

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

Clean-up:

```bash
helm delete cow-demo
kubectl delete ns demo
```
Empty file.
Empty file.
36 changes: 36 additions & 0 deletions charts/cow-demo/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- $name := $.Values.name -}}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $name }}
labels:
app: {{ $name }}
app.kubernetes.io/name: {{ $name }}
spec:
replicas: {{ $.Values.replicaCount }}
selector:
matchLabels:
app: {{ $name }}
app.kubernetes.io/name: {{ $name }}
template:
metadata:
labels:
app: {{ $name }}
app.kubernetes.io/name: {{ $name }}
spec:
containers:
- name: webapp
image: "{{ $.Values.image }}:{{ $.Values.tag }}"
imagePullPolicy: Always
env:
- name: CONTAINER_COLOR
value: {{ $.Values.pet.color }}
- name: PETS
value: {{ $.Values.pet.type }}
ports:
- name: http
containerPort: 8080
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
34 changes: 34 additions & 0 deletions charts/cow-demo/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{- if $.Values.ingress.enabled -}}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $.Values.name }}
{{- with $.Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if $.Values.ingress.className }}
ingressClassName: {{ $.Values.ingress.className }}
{{- end }}
rules:
- {{- if $.Values.ingress.host }}
host: {{ $.Values.ingress.host }}
{{- end }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ $.Values.name }}
port:
number: {{ $.Values.port }}
{{- if $.Values.ingress.tls }}
tls:
- hosts:
- {{ $.Values.ingress.host | quote }}
secretName: {{ $.Values.ingress.tls.secretName }}
{{- end }}
{{- end }}
19 changes: 19 additions & 0 deletions charts/cow-demo/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- $name := $.Values.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: {{ $.Values.port }}
protocol: TCP
targetPort: 8080
27 changes: 27 additions & 0 deletions charts/cow-demo/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: cow-demo
image: devprofr/cow-demo
tag: 1.0.8830193847
replicaCount: 2
port: 80
ingress:
enabled: false
className: "nginx"
host: ""
annotations: {}
# nginx.ingress.kubernetes.io/ssl-redirect: "false"
# nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
# cert-manager.io/cluster-issuer: letsencrypt-prod
tls:
secretName: "cow-demo-tls"
pet:
# choice: cows, chameleons, cowmeleons
type: cows
# choice: red, orange, yellow, olive, green, teal, blue, violet, purple, pink, black
color: blue
resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 64Mi
Loading

0 comments on commit 364c6b2

Please sign in to comment.