diff --git a/Makefile b/Makefile index 4c1c212..7968dfe 100644 --- a/Makefile +++ b/Makefile @@ -1,34 +1,39 @@ -DOCKER_REPO ?= gcr.io/online-bridge-hackathon-2020 +# Project / Org +GCP_PROJECT ?= globalbridge-app +GKE_ZONE ?= europe-west4-b + +# Service / App +GKE_CLUSTER_NAME ?= prod-cluster +RELEASE_NAME ?= deal +K8S_NS ?= prod-${RELEASE_NAME} +EXTERNAL_ADDRESS ?= ${RELEASE_NAME}.prod.globalbridge.app + +# Docker Config +DOCKER_REPO ?= gcr.io/${GCP_PROJECT} VERSION ?= $(shell cat VERSION) -DOCKER_TAG=${DOCKER_REPO}/deal-api:${VERSION} - -EXTERNAL_ADDRES ?= deal.hackathon.globalbridge.app - -DDS_K8S_NS ?= deal-api -GCP_PROJECT ?= online-bridge-hackathon-2020 -GKE_CLUSTER_NAME ?= hackathon-cluster -GKE_ZONE ?= europe-west3-b +DOCKER_TAG = ${DOCKER_REPO}/${RELEASE_NAME}:${VERSION} release: build push -build: +build: docker build -t ${DOCKER_TAG} . push: docker push ${DOCKER_TAG} deploy: set_gcp_context ensure_ns - helm upgrade --install deal-api ./chart \ + helm upgrade --install ${RELEASE_NAME} ./chart \ --set image="${DOCKER_TAG}" \ - --set externalHostname="${EXTERNAL_ADDRES}" \ - --namespace ${DDS_K8S_NS} \ + --set externalHostname="${EXTERNAL_ADDRESS}" \ + --namespace ${K8S_NS} \ --history-max=10 uninstall: set_gcp_context - helm del deal-api --namespace ${DDS_K8S_NS} + @echo Warning: Are you sure you want to delete this Production service ${RELEASE_NAME} [N/y] + read answer; [ "x$$answer" = "xy" ] && helm del ${RELEASE_NAME} --namespace ${K8S_NS} set_gcp_context: gcloud container clusters get-credentials ${GKE_CLUSTER_NAME} --zone ${GKE_ZONE} --project ${GCP_PROJECT} ensure_ns: - kubectl create ns ${DDS_K8S_NS} || : + kubectl create ns ${K8S_NS} || : diff --git a/VERSION b/VERSION index 8acdd82..6e8bf73 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.1 +0.1.0 diff --git a/chart/Chart.yaml b/chart/Chart.yaml new file mode 100644 index 0000000..86b0125 --- /dev/null +++ b/chart/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: A helm chart for Deal API +name: deal +version: 0.1.0 diff --git a/chart/templates/deal.yaml b/chart/templates/deal.yaml new file mode 100644 index 0000000..d3fac88 --- /dev/null +++ b/chart/templates/deal.yaml @@ -0,0 +1,60 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-deployment + labels: + app: {{ .Release.Name }} +spec: + replicas: {{ int .Values.replicas }} + selector: + matchLabels: + app: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }} + spec: + containers: + - name: {{ .Release.Name }}-api + image: {{ .Values.image }} + imagePullPolicy: Always + ports: + - containerPort: {{ .Values.targetPort }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-service +spec: + selector: + app: {{ .Release.Name }} + ports: + - port: 80 + targetPort: {{ .Values.targetPort }} + protocol: TCP + name: http +--- +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + annotations: + kubernetes.io/ingress.class: nginx + nginx.ingress.kubernetes.io/force-ssl-redirect: "true" + cert-manager.io/cluster-issuer: letsencrypt-production + labels: + app: {{ .Release.Name }} + name: {{ .Release.Name }}-ingress +spec: + tls: + - hosts: + - {{ .Values.externalHostname }} + secretName: {{ .Values.tlsSecret }} + rules: + - host: "{{ .Values.externalHostname }}" + http: + paths: + - path: / + backend: + serviceName: {{ .Release.Name }}-service + servicePort: 80 diff --git a/chart/values.yaml b/chart/values.yaml new file mode 100644 index 0000000..34e3e4c --- /dev/null +++ b/chart/values.yaml @@ -0,0 +1,5 @@ +image: gcr.io/globalbridge-app/deal +replicas: 1 +externalHostname: deal.prod.globalbridge.app +tlsSecret: deal-tls-secret +targetPort: 8080