Skip to content

Commit

Permalink
Merge pull request #9 from AustrianDataLAB/devel
Browse files Browse the repository at this point in the history
Trial new img tag workflow w/shell script updates
  • Loading branch information
adammccartney authored Dec 19, 2022
2 parents b8bba28 + 5699fe6 commit c32b4e8
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 25 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ jobs:
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=match,pattern=\d.\d.\d.*
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
Expand Down
57 changes: 41 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,61 @@ This was taken from https://vzilla.co.uk/vzilla-blog/building-the-home-lab-kuber

You have a valid student user and have logged into RancherUI https://rancher.k8s.dev.austrianopensciencecloud.org/

## Deployment
### Note your username and path to kubeconf file
your user starts with 'u-' and you can run in the RacherUI:

Clone this git repository and change into the pacman directory

```bash
kubectl get all
git clone git@github.com:AustrianDataLAB/pacman.git
cd pacman
```
that ll tell you, that your user 'u-***' doesnt have rights to see something. Copy this string!

Download the kubeconfig file from the RancherUI, top right and save it somewhere on your laptop.
## Deployment

You will need to set three environment variables in your local environment in
order for the shell scripts to run correctly, and for the pacman application to
be deployed to the cluster.

```bash
export KUBECONFIG=~/Downloads/local-2.yaml
export pacman='u-r6hs89045r2f'
1. `$KUBECONFIG`, the absolute path to the kube config file for the cluster.
Download from the RancherUI and save locally.
2. `$pacman`, the target [namespace](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/)
where the app will be deployed. Appears in the RancherUI, in dropdown menu
on the top right under "Only User Namespaces". Follows the form `u-XXXXX`
where `XXXXX` are random characters.
3. `$host`, the DNS hostname for the cluster. In the url:
"https://rancher.caas-0005.dev.austrianopencloudcommunity.org"
the DNS hostname is: "caas-0005.dev.austrianopencloudcommunity.org"

### Create .env file

Modify the values as they apply to you and save them to a file named `.env`

```bash
cat <<EOF > .env
export KUBECONFIG=/home/user/k8s/clusters/caas-0005.dev/kubeconfig.yaml
export pacman=u-XXXXXX
export host=caas-0005.dev.austrianopencloudcommunity.org
EOF
```


### Using a Script for installation
Clone repo, checkout branch=`main`
Then: run ```chmod +X pacman-install.sh``` and then run file ```./pacman-install.sh```

Make the script executable, source the environment file and run the script.

```bash
git clone git@github.com:entlein/pacman.git
chmod +X pacman-install.sh
chmod +x pacman-install.sh
source .env
./pacman-install.sh
```



#### Uninstall using a Script

Run file `./pacman-uninstall.sh`. This will delete all objects created by `./pacman-install.sh`

Alternatively, run `./pacman-uninstall.sh keeppvc`. This will delete all objects except for the pacman namespace and the persistent volume claim. You can use this to demonstrate persistence of the MongoDB data by installing, playing a game and recording a high score, then unininstalling with the `keeppvc` argument. You can then run the installation again and the high score will persist.
Alternatively, run `./pacman-uninstall.sh keeppvc`. This will delete all objects except for
the pacman namespace and the persistent volume claim. You can use this to demonstrate persistence
of the MongoDB data by installing, playing a game and recording a high score, then unininstalling
with the `keeppvc` argument. You can then run the installation again and the high score will persist.

#### Note of caution: Cert manager will only sign very few official certificates per 168 hrs
Before adding the ingress/cert, make sure you understand what that does and that you know how to keep your certificate 'safe'
Expand Down
2 changes: 1 addition & 1 deletion deployments/pacman-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
name: pacman
spec:
containers:
- image: adlsregistrysbx.azurecr.io/tutorials/pacman:latest
- image: ghcr.io/austriandatalab/pacman:latest
name: pacman
ports:
- containerPort: 8080
Expand Down
4 changes: 2 additions & 2 deletions ingress/ingress.txt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
spec:
ingressClassName: nginx
rules:
- host: ingress-$pacman.k8s.dev.austrianopensciencecloud.org
- host: ingress-$pacman.$host
http:
paths:
- backend:
Expand All @@ -22,4 +22,4 @@ spec:
#tls:
#- hosts:
# - ingress-$pacman.k8s.dev.austrianopensciencecloud.org
# secretName: $pacman-ingress-tls
# secretName: $pacman-ingress-tls
5 changes: 1 addition & 4 deletions pacman-install.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/sh
#Taken from this blog: https://vzilla.co.uk/vzilla-blog/building-the-home-lab-kubernetes-playground-part-9
#Please modify the next two lines with your values
export KUBECONFIG=~/Downloads/local-3.yaml
export pacman='u-rXXXX'
# Taken from this blog: https://vzilla.co.uk/vzilla-blog/building-the-home-lab-kubernetes-playground-part-9

echo "Installing your PacMan app on K8s"
envsubst < persistentvolumeclaim/mongo-pvc.txt.yaml > persistentvolumeclaim/mongo-pvc.yaml
Expand Down
5 changes: 3 additions & 2 deletions pacman-uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
export KUBECONFIG=~/Downloads/local-3.yaml
export pacman='u-rXXXXXXX'

#kubectl delete -n $pacman -f security/rbac.yaml
kubectl delete -n $pacman -f security/secret.yaml
kubectl delete -n $pacman -f deployments/mongo-deployment.yaml
Expand All @@ -22,3 +21,5 @@ echo "cleaning up your files"
rm persistentvolumeclaim/mongo-pvc.yaml
rm security/secret.yaml
rm ingress/ingress.yaml


0 comments on commit c32b4e8

Please sign in to comment.