Skip to content

Commit

Permalink
Feature/Use container image and helm charts (#11)
Browse files Browse the repository at this point in the history
* Use new helm chart repo

* Do not create a container image if only markdown was modified

* Use new container image registry

* Add static badge to application README

* Cosmetic code changes

* Rename go application module

* Add missing quantifier in ci

* Update PKG

* Update CI
  • Loading branch information
devpro authored Sep 12, 2024
1 parent 9eff022 commit 084bb1b
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 46 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ jobs:
with:
base: ${{ github.ref }}
filters: |
game-2048: src/game-2048/**
cow-demo: src/cow-demo/**
rancher-helloworld: src/rancher-helloworld/**
game-2048: src/game-2048/**/*.!(md)
cow-demo: src/cow-demo/**/*.!(md)
rancher-helloworld: src/rancher-helloworld/**/*.!(md)
code-check:
runs-on: ubuntu-latest
steps:
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
with:
base: ${{ github.ref }}
filters: |
game-2048: src/game-2048/**
cow-demo: src/cow-demo/**
rancher-helloworld: src/rancher-helloworld/**
game-2048: src/game-2048/**/*.!(md)
cow-demo: src/cow-demo/**/*.!(md)
rancher-helloworld: src/rancher-helloworld/**/*.!(md)
build:
if: ${{ github.ref_name == 'main' }}
runs-on: ubuntu-latest
Expand All @@ -51,8 +51,6 @@ jobs:
helm repo update
- name: Host charts repository on GitHub Pages
uses: helm/chart-releaser-action@v1.6.0
with:
skip_existing: true
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Checkout gh-pages branch
Expand All @@ -75,12 +73,12 @@ jobs:
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
if: ${{ github.ref_name == 'main' }}
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Wether you're looking for simple way to automate an infrastructure or running de
Download and source the files (targetting `develop` branch):

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

Expand Down Expand Up @@ -49,7 +49,7 @@ Browse the [catalog of Helm charts](charts/README.md).
Use the container images we provide for our demonstrations, for instance:

```bash
docker run --rm -p 8080:8080 ghcr.io/suse/cow-demo:1.0.10773428519
docker run --rm -p 8080:8080 ghcr.io/suse/cow-demo
```

Open the [web application](http://localhost:8080/) and enjoy the live display!
Expand Down
2 changes: 1 addition & 1 deletion charts/cow-demo/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: cow-demo
description: Helm chart for Cow Demo Application
type: application
version: 0.1.1
version: 0.1.2
appVersion: "2.0.0"
home: https://github.com/SUSE/lab-setup/tree/main/charts/cow-demo
maintainers:
Expand Down
4 changes: 2 additions & 2 deletions charts/cow-demo/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: cow-demo
image: devprofr/cow-demo
tag: 1.0.8830193847
image: ghcr.io/suse/cow-demo
tag: 1.0.10775272363
replicaCount: 2
port: 80
ingress:
Expand Down
2 changes: 1 addition & 1 deletion charts/game-2048/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: game-2048
description: Helm chart for Game 2048
type: application
version: 0.1.1
version: 0.1.2
appVersion: "1.0.0"
home: https://github.com/SUSE/lab-setup/tree/main/charts/game-2048
maintainers:
Expand Down
4 changes: 2 additions & 2 deletions charts/game-2048/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: game-2048
image: devprofr/game-2048
tag: "1.0.8328752292"
image: ghcr.io/suse/game-2048
tag: "1.0.10775272363"
replicaCount: 1
port: 80
ingress:
Expand Down
14 changes: 6 additions & 8 deletions scripts/kubernetes/certificate-management.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ k8s_install_certmanager() {
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/${version}/cert-manager.crds.yaml
helm upgrade --install cert-manager jetstack/cert-manager \
--namespace cert-manager --create-namespace \
--version ${version} \
2>/dev/null
--version ${version}
kubectl wait pods -n cert-manager -l app.kubernetes.io/instance=cert-manager --for condition=Ready 2>/dev/null
}

Expand All @@ -28,20 +27,19 @@ k8s_install_certmanager() {
# Ingress class name (traefik, nginx, etc.)
# administrator email address (to receive notifications for Let's Encrypt)
# Examples:
# k8s_create_letsencryptclusterissuer traefik john.wick@google.com
# k8s_create_letsencryptclusterissuer traefik john.wick@thecontinental.hotel
#######################################
k8s_create_letsencryptclusterissuer() {
local ingressClassname=$1
local emailAddress=$2

echo "Creating certificate issuers using Let's Encrypt..."
# TODO move charts to this repository
helm repo add devpro https://devpro.github.io/helm-charts
helm repo add suse-lab-setup https://opensource.suse.com/lab-setup
helm repo update
helm upgrade --install letsencrypt devpro/letsencrypt --namespace cert-manager \
helm upgrade --install letsencrypt suse-lab-setup/letsencrypt \
--namespace cert-manager \
--set ingress.className=${ingressClassname} \
--set registration.emailAddress=${emailAddress} \
2>/dev/null
--set registration.emailAddress=${emailAddress}
sleep 5
while kubectl get clusterissuers -o json | jq -e '.items[] | select(.status.conditions[] | select(.type == "Ready" and .status != "True"))' > /dev/null; do
sleep 1
Expand Down
1 change: 1 addition & 0 deletions src/cow-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# generated local binary
cow-demo
cow-demo*
30 changes: 16 additions & 14 deletions src/cow-demo/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Cow Demo Application

[![Badge](https://badgen.net/static/Container%20Image/GitHub%20Packages/green)](https://github.com/SUSE/lab-setup/pkgs/container/cow-demo)

Cow Demo is a nice web application, written in Go, used for demonstrating Kubernetes and load balancing.

💡 This is a hard fork of [oskapt/rancher-demo](https://github.com/oskapt/rancher-demo) who hasn't been updated since 2021.
Expand All @@ -11,6 +13,20 @@ It will create a colored icon for each replica within a ReplicaSet and indicate
Replicas which haven't been heard from will begin to fade out, until after a configurable number of seconds they will disappear.
This is useful for demonstrating scaling up/down an upgraded application.

## Quickstart with a container

If you have a container engine running, you can start right away with the image:

```bash
docker run --rm -p 8080:8080 ghcr.io/suse/cow-demo
```

Open the [web application](http://localhost:8080/) and enjoy the interactive display!

## Deploy in an environment

The recommanded way to run the application is to deploy in a Kubernetes cluster with with the [Helm chart](https://github.com/SUSE/lab-setup/tree/main/charts/cow-demo).

## Configuration

Environment variables:
Expand Down Expand Up @@ -39,20 +55,6 @@ Environment variables:
- chameleons
- cowmeleons

## Quickstart with a container

If you have a container engine running, you can start right away with the image:

```bash
docker run --rm -p 8080:8080 ghcr.io/suse/cow-demo:1.0.10773428519
```

Open the [web application](http://localhost:8080/) and enjoy the interactive display!

## Deploy in an environment

The recommanded way to run the application is to deploy in a Kubernetes cluster with with the [Helm chart](https://github.com/SUSE/lab-setup/tree/main/charts/cow-demo).

## Local development

### How to test
Expand Down
2 changes: 1 addition & 1 deletion src/cow-demo/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/devpro/cow-demo
module github.com/suse/lab-setup/cow-demo

go 1.22

Expand Down
4 changes: 3 additions & 1 deletion src/game-2048/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 2048 game

[![Badge](https://badgen.net/static/Container%20Image/GitHub%20Packages/green)](https://github.com/SUSE/lab-setup/pkgs/container/game-2048)

Let's play 2048 game in a browser!

💡 This is a hard fork of [gabrielecirulli/2048](https://github.com/gabrielecirulli/2048) which hasn't been updated since 2017.
Expand All @@ -9,7 +11,7 @@ Let's play 2048 game in a browser!
If you have a container engine running, you can start right away with the image:

```bash
docker run --rm -p 8080:80 ghcr.io/suse/game-2048:1.0.10773428519
docker run --rm -p 8080:80 ghcr.io/suse/game-2048
```

Open the [web application](http://localhost:8080/) and enjoy the game!
Expand Down
4 changes: 3 additions & 1 deletion src/rancher-helloworld/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Rancher Hello World

[![Badge](https://badgen.net/static/Container%20Image/GitHub%20Packages/green)](https://github.com/SUSE/lab-setup/pkgs/container/rancher-helloworld)

This small web application is interesting as a first workload to install in a Kubernetes cluster. It shows data about hostname, services and request headers.

💡 This is a hard fork of [rancher/hello-world](https://github.com/rancher/hello-world) which hasn't been updated since 2018.
Expand All @@ -9,7 +11,7 @@ This small web application is interesting as a first workload to install in a Ku
If you have a container engine running, you can start right away with the image:

```bash
docker run --rm -p 8080:80 ghcr.io/suse/rancher-helloworld:1.0.10773428519
docker run --rm -p 8080:80 ghcr.io/suse/rancher-helloworld
```

Open the [web application](http://localhost:8080/) and look at the information!
Expand Down
2 changes: 1 addition & 1 deletion src/rancher-helloworld/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/devpro/rancher-helloworld
module github.com/suse/lab-setup/rancher-helloworld

go 1.22
2 changes: 1 addition & 1 deletion src/rancher-helloworld/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"regexp"
"strings"

"github.com/devpro/rancher-helloworld/templates"
"github.com/suse/lab-setup/rancher-helloworld/templates"
)

const defaultListenPort = "80"
Expand Down

0 comments on commit 084bb1b

Please sign in to comment.