Skip to content

Commit

Permalink
Update for testing env
Browse files Browse the repository at this point in the history
  • Loading branch information
wraitii committed Dec 16, 2021
1 parent bcb30f8 commit 5655357
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 14 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/deploy-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: deploy-test
on:
push:
env:
GKE_CLUSTER: sltech-briq-k8s-cluster
GKE_ZONE: europe-west3-c

jobs:
deploy:
name: "Deploy to test env"
environment: production
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}

# Configure Docker to use the gcloud command-line tool as a credential helper for authentication
- run: |-
gcloud auth configure-docker europe-west3-docker.pkg.dev
# Get the GKE credentials
- uses: google-github-actions/get-gke-credentials@main
with:
cluster_name: ${{ env.GKE_CLUSTER }}
location: ${{ env.GKE_ZONE }}
credentials: ${{ secrets.GCP_SA_KEY }}

- uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'npm'

- run: npm ci --include=dev

- name: Install ytt
run: |-
# Taken from install script.
binary_type=linux-amd64
ytt_version=v0.37.0
ytt_checksum=1aad12386f6bae1a78197acdc7ec9e60c441f82c4ca944df8d3c78625750fe59
wget -nv -O- https://github.com/vmware-tanzu/carvel-ytt/releases/download/${ytt_version}/ytt-${binary_type} > ytt
echo "${ytt_checksum} ytt" | shasum -c -
chmod +x ytt
sudo ln -s "$(pwd)/ytt" /usr/local/bin/ytt
ytt --version
- name: Deploy
run: |-
K8S_ENV=test infra/deploy.sh
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ jobs:
- name: Deploy
run: |-
infra/deploy.sh
K8S_ENV=prod infra/deploy.sh
4 changes: 3 additions & 1 deletion infra/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set -e
#exit 0

export TAG=${TAG:=$(git rev-parse HEAD)}
export K8S_ENV=${K8S_ENV:="test"}

infra/run-docker.sh
infra/render.sh
kubectl apply -f infra/dist/manifests.yaml --validate=true
kubectl apply -f infra/dist/manifests-${K8S_ENV}.yaml --validate=true
2 changes: 1 addition & 1 deletion infra/deploy.yaml → infra/k8s/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: #@ data.values.name
image: #@ "europe-west3-docker.pkg.dev/healthy-saga-329513/sltech-briq/" + data.values.name + ":" + data.values.image_tag
image: #@ "europe-west3-docker.pkg.dev/healthy-saga-329513/sltech-briq/" + data.values.image_name + ":" + data.values.image_tag
ports:
- containerPort: 80
resources:
Expand Down
10 changes: 3 additions & 7 deletions infra/ingress.yaml → infra/k8s/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ metadata:
name: #@ data.values.name
labels: #@ data.values.defaultLabels
annotations:
kubernetes.io/ingress.global-static-ip-name: lb-sltech-company-ipv4-2
kubernetes.io/ingress.global-static-ip-name: #@ data.values.static_ip
networking.gke.io/v1beta1.FrontendConfig: #@ data.values.name
networking.gke.io/managed-certificates: #@ data.values.name + "-managed-cert"
spec:
rules:
#@ arr = ["sltech.company", "www.sltech.company", "briq.construction", "www.briq.construction"]
#@ arr = data.values.sites
#@ for i in arr:
- host: #@ i
http:
Expand Down Expand Up @@ -40,8 +40,4 @@ kind: ManagedCertificate
metadata:
name: #@ data.values.name + "-managed-cert"
spec:
domains:
- sltech.company
- www.sltech.company
- briq.construction
- www.briq.construction
domains: #@ data.values.sites
File renamed without changes.
7 changes: 4 additions & 3 deletions infra/render.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
set -e

TAG=${TAG:=$(git rev-parse HEAD)}
K8S_ENV=${K8S_ENV:="test"}

mkdir -p infra/dist
ytt -f infra/schema.yaml -f infra/ --data-value "image_tag=$TAG" > infra/dist/manifests.yaml
ytt -f infra/schema.yaml -f infra/vals-${K8S_ENV}.yaml -f infra/k8s/ --data-value "image_tag=$TAG" > infra/dist/manifests-${K8S_ENV}.yaml
echo "validating client-side"
kubectl apply -f infra/dist/manifests.yaml --validate=true --dry-run=client
kubectl apply -f infra/dist/manifests-${K8S_ENV}.yaml --validate=true --dry-run=client
echo "validating server-side"
kubectl apply -f infra/dist/manifests.yaml --validate=true --dry-run=server
kubectl apply -f infra/dist/manifests-${K8S_ENV}.yaml --validate=true --dry-run=server
6 changes: 5 additions & 1 deletion infra/schema.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#@data/values-schema
---
name: briq-builder
image_tag: ""
env: test
static_ip: lb-sltech-company-ipv4-2
sites: [""]
#@schema/type any=True
defaultLabels:
appname: briq-builder
env: test
image_name: briq-builder
image_tag: ""
10 changes: 10 additions & 0 deletions infra/vals-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#@data/values
---
name: briq-builder
env: prod
static_ip: lb-sltech-company-ipv4-2
sites: ["www.briq.construction", "briq.construction", "www.sltech.company", "sltech.company"]
#@schema/type any=True
defaultLabels:
appname: briq-builder
env: prod
10 changes: 10 additions & 0 deletions infra/vals-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#@data/values
---
name: dev-briq-builder
env: test
static_ip: lb-sltech-company-ipv4-4
sites: ["test.sltech.company"]
#@schema/type any=True
defaultLabels:
appname: dev-briq-builder
env: test

0 comments on commit 5655357

Please sign in to comment.