Skip to content

Commit

Permalink
Deploy to London
Browse files Browse the repository at this point in the history
  • Loading branch information
meezaan committed Jun 15, 2023
1 parent 50201b0 commit 9487e62
Show file tree
Hide file tree
Showing 2 changed files with 192 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ jobs:
ghcr.io/islamic-network/alquran.cloud:latest
ghcr.io/islamic-network/alquran.cloud:${{ github.ref_name }}
deploy-london:
needs: docker-build-and-push
runs-on: ubuntu-latest
container:
image: meezaan/kubectl:latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Update Consumer and Keys
run: |
export K8S_URL=${{ secrets.K8S_LONDON_URL }}
export K8S_TOKEN=${{ secrets.K8S_LONDON_TOKEN }}
export K8S_CA=${{ secrets.K8S_LONDON_CA }}
echo "$K8S_CA" | base64 --decode > cert.crt
export REF_NAME=${{ github.ref_name }}
COMMIT_TAG=$REF_NAME
export COMMIT_TAG=$REF_NAME
envsubst <./.k8s/manifest-london.yml >./.k8s/manifest-london.yml.out
mv ./.k8s/manifest-london.yml.out ./.k8s/manifest-london.yml
kubectl apply -f .k8s/manifest-london.yml --kubeconfig=/dev/null --server=$K8S_URL --certificate-authority=cert.crt --token=$K8S_TOKEN
deploy-dubai:
needs: docker-build-and-push
Expand Down
171 changes: 171 additions & 0 deletions .k8s/manifest-london.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# Deployment
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: alquran-cloud-app
namespace: alquran-cloud
spec:
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
selector:
matchLabels:
app: alquran-cloud-app
template:
metadata:
labels:
app: alquran-cloud-app
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
containers:
- name: apache-exporter-sidecar
image: lusotycoon/apache-exporter
resources:
requests:
cpu: "20m"
memory: 16Mi
limits:
cpu: "100"
memory: 128Mi
args:
- '--scrape_uri=http://localhost:8080/server-status?auto'
ports:
- containerPort: 9117
protocol: TCP
- name: alquran-cloud-app
image: ghcr.io/islamic-network/alquran.cloud:$COMMIT_TAG
env:
- name: API_BASE_URI
value: http://alquran-cloud-api/v1/
livenessProbe:
httpGet:
path: /liveness
port: 8080
initialDelaySeconds: 7
periodSeconds: 30
timeoutSeconds: 5
failureThreshold: 3
startupProbe:
httpGet:
path: /liveness
port: 8080
periodSeconds: 7
failureThreshold: 3
resources:
requests:
cpu: "100m"
memory: 180Mi
limits:
cpu: "200m"
memory: 380Mi
ports:
- containerPort: 8080
protocol: TCP
---
# HPA
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: alquran-cloud-app
namespace: alquran-cloud
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: alquran-cloud-app
minReplicas: 2
maxReplicas: 5
targetCPUUtilizationPercentage: 60
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: alquran-cloud-ingress
namespace: alquran-cloud
annotations:
konghq.com/protocols: "https"
konghq.com/https-redirect-status-code: "301"
kubernetes.io/tls-acme: "true"
cert-manager.io/cluster-issuer: letsencrypt-prod
kubernetes.io/ingress.class: kong
spec:
tls:
- hosts:
- alquran.cloud
- "www.alquran.cloud"
secretName: "alquran-cloud-app-tls"
rules:
- host: alquran.cloud
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: alquran-cloud-app
port:
number: 80
- host: www.alquran.cloud
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: alquran-cloud-app
port:
number: 80
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: alquran-cloud-app-metrics
namespace: monitoring
labels:
release: lke-monitor
spec:
selector:
matchLabels:
name: alquran-cloud-app-metrics
namespaceSelector:
any: true
endpoints:
- port: "metrics"
interval: 30s
---
# Service
apiVersion: v1
kind: Service
metadata:
name: alquran-cloud-app
namespace: alquran-cloud
spec:
ports:
- port: 80
targetPort: 8080
selector:
app: alquran-cloud-app
---
apiVersion: v1
kind: Service
metadata:
name: alquran-cloud-app-metrics
namespace: alquran-cloud
labels:
name: alquran-cloud-app-metrics
spec:
type: ClusterIP
selector:
app: alquran-cloud-app
ports:
- name: metrics
port: 9117
targetPort: 9117

0 comments on commit 9487e62

Please sign in to comment.