-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (74 loc) · 3.34 KB
/
local_k8s.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Deploying Wordpress on Kubernetes
on:
- push
- pull_request
env:
tf_version: 'latest'
tg_version: 'latest'
tf_working_dir: 'environments/dev'
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push openresty Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: ./docker
file: docker/Dockerfile_openresty
push: true
tags: ghcr.io/katzefudder/openresty:latest
- name: Build and push Wordpress Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: ./docker
file: docker/Dockerfile_wordpress
push: true
tags: ghcr.io/katzefudder/wordpress:latest
Wordpress_on_Minikube:
runs-on: ubuntu-latest
name: Wordpress on Kubernetes
steps:
- name: Install dependencies
run: |
mkdir tenv && wget https://github.com/tofuutils/tenv/releases/download/v3.2.10/tenv_v3.2.10_Linux_x86_64.tar.gz -O tenv.tar.gz && tar xzf tenv.tar.gz -C tenv && sudo ln -sf $(pwd)/tenv/* /usr/local/bin
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 && chmod 700 get_helm.sh && ./get_helm.sh && helm version
- name: 'Checkout'
uses: actions/checkout@master
- name: Install required Terraform & Terragrunt versions
run: cd environments && /usr/local/bin/tenv tf install && /usr/local/bin/tenv tg install
#### K3D
- name: Install K3D
run: wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=v5.4.4 bash
- name: Start K3D
run: k3d cluster create --api-port 6550 -p "80:80@loadbalancer" --k3s-arg="--disable=traefik@server:0"
#### Install kube-prometheus-stack https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack
# hack: for having CRDs available, install helm chart then remove right after
- name: Install kube-prometheus-stack helm chart
run: helm repo add prometheus-community https://prometheus-community.github.io/helm-charts && helm repo update && helm install prometheus-stack prometheus-community/kube-prometheus-stack && helm uninstall prometheus-stack
- name: Create monitoring namespace
run: kubectl create ns monitoring
#### Terraforming
- name: 'Terragrunt Init'
run: cd $tf_working_dir && terragrunt init
- name: 'Terragrunt Apply'
run: cd $tf_working_dir && terragrunt apply --auto-approve --input=false
#### Bit of debugging and testing
- name: show running pods
run: kubectl get pods -n dev-wordpress
- name: port forwarding wordpress to localhost:8080
run: kubectl port-forward -n dev-wordpress svc/wordpress 8080 &
- name: testing output
run: curl --fail --silent -IL localhost:8080/wp-admin/install.php | grep "HTTP/1.1 200 OK"