diff --git a/.k8s/manifest-asia.yml b/.k8s/manifest-asia.yml new file mode 100644 index 0000000..737ba24 --- /dev/null +++ b/.k8s/manifest-asia.yml @@ -0,0 +1,167 @@ +# Deployment +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: alquran-cloud-app + namespace: alquran-cloud +spec: + replicas: 3 + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 2 + maxUnavailable: 0 + selector: + matchLabels: + app: alquran-cloud-app + template: + metadata: + labels: + app: alquran-cloud-app + spec: + 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: islamicnetwork/alquran.cloud:$COMMIT_TAG + env: + - name: API_BASE_URI + value: http://alquran-cloud-api/ + 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: 3 + maxReplicas: 5 + targetCPUUtilizationPercentage: 80 +--- +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 + diff --git a/.k8s/manifest-europe.yml b/.k8s/manifest-europe.yml index 46ec3c4..7234f1e 100644 --- a/.k8s/manifest-europe.yml +++ b/.k8s/manifest-europe.yml @@ -44,9 +44,9 @@ spec: httpGet: path: /liveness port: 8080 - initialDelaySeconds: 15 - periodSeconds: 10 - timeoutSeconds: 3 + initialDelaySeconds: 7 + periodSeconds: 30 + timeoutSeconds: 5 failureThreshold: 3 startupProbe: httpGet: @@ -64,4 +64,104 @@ spec: 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: 3 + maxReplicas: 5 + targetCPUUtilizationPercentage: 80 +--- +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