-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
infra: use helm chart for deployments
Test secContext
- Loading branch information
RoRu
committed
Aug 29, 2022
1 parent
5fcb2af
commit 6cb836b
Showing
19 changed files
with
520 additions
and
369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ jobs: | |
build: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
image_name: ${{ steps.build.outputs.image_name }} | ||
image_name: '${{ steps.build.outputs.image_name }}' | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
|
@@ -24,7 +24,7 @@ jobs: | |
environment: production | ||
needs: build | ||
container: | ||
image: qwolphin/kdsl:1.21.8 | ||
image: ghcr.io/helmfile/helmfile-ubuntu:v0.145.3 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
|
@@ -38,33 +38,23 @@ jobs: | |
- name: GCP Auth | ||
uses: google-github-actions/[email protected] | ||
with: | ||
credentials_json: ${{ secrets.GCP_SA_KEY }} | ||
credentials_json: '${{ secrets.GCP_SA_KEY }}' | ||
- name: Get GKE credentials | ||
uses: google-github-actions/[email protected] | ||
with: | ||
cluster_name: ${{ secrets.GKE_CLUSTER }} | ||
location: ${{ secrets.GKE_CLUSTER_REGION }} | ||
cluster_name: '${{ secrets.GKE_CLUSTER }}' | ||
location: '${{ secrets.GKE_CLUSTER_REGION }}' | ||
|
||
- name: Render kdsl resources into yaml | ||
env: | ||
MAINNET_RPC: '${{ secrets.MAINNET_RPC }}' | ||
POLYGON_RPC: '${{ secrets.POLYGON_RPC }}' | ||
RECIPE: "chain${{ matrix.CHAIN_ID }}" | ||
DOMAIN: cache-api-${{ matrix.CHAIN_ID }}.aave.com | ||
CHAIN_ID: ${{ matrix.CHAIN_ID }} | ||
IMAGE: ${{ needs.build.outputs.image_name }} | ||
DOMAIN: 'cache-api-${{ matrix.CHAIN_ID }}.aave.com' | ||
CHAIN_ID: '${{ matrix.CHAIN_ID }}' | ||
IMAGE: '${{ needs.build.outputs.image_name }}' | ||
COMMIT_SHA: "${{ github.sha }}" | ||
NAMESPACE: cache-${{ matrix.CHAIN_ID }} | ||
NAMESPACE: 'cache-${{ matrix.CHAIN_ID }}' | ||
ENV_NAME: production | ||
HELM_PLUGINS: '/root/.local/share/helm/plugins' | ||
run: | | ||
cd k8s/ | ||
kubectl config set-context --current --namespace=${{ env.NAMESPACE }} | ||
python3 main.py > ../rendered.yml | ||
- name: Apply k8s resources | ||
run: | | ||
kubectl apply -f rendered.yml --dry-run=server | ||
kubectl apply -f rendered.yml | ||
sleep 3 | ||
kubectl wait --for condition=ready --timeout 90s pods -l "commit_sha=${{ github.sha }}" || \ | ||
{ kubectl get pods && exit 1; } | ||
helmfile apply --suppress-diff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: v2 | ||
name: aave-caching-server | ||
description: A Helm chart for Kubernetes | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
type: application | ||
|
||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
version: 0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "chart.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "chart.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "chart.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{- define "common.env" -}} | ||
{{- with .Values.common.env }} | ||
{{ toYaml . }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "common.labels" -}} | ||
{{- with .Values.common.labels }} | ||
{{- toYaml . }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common annotations | ||
*/}} | ||
{{- define "common.annotations" -}} | ||
{{- with .Values.common.annotations }} | ||
{{- toYaml . }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: api | ||
labels: | ||
{{- include "common.labels" . | nindent 4 }} | ||
component: api | ||
annotations: | ||
{{- include "common.annotations" . | nindent 4 }} | ||
spec: | ||
strategy: | ||
type: RollingUpdate | ||
rollingUpdate: | ||
maxSurge: 1 | ||
maxUnavailable: 0 | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
component: api | ||
template: | ||
metadata: | ||
annotations: | ||
{{- with .Values.api.podAnnotations }} | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- include "common.annotations" . | nindent 8 }} | ||
labels: | ||
{{- include "common.labels" . | nindent 8 }} | ||
component: api | ||
spec: | ||
automountServiceAccountToken: false | ||
enableServiceLinks: false | ||
containers: | ||
- name: api | ||
env: | ||
- name: REDIS_HOST | ||
value: redis | ||
{{- include "common.env" . | nindent 12 }} | ||
image: "{{ .Values.common.image }}" | ||
imagePullPolicy: Always | ||
ports: | ||
- name: http | ||
containerPort: 3000 | ||
protocol: TCP | ||
livenessProbe: | ||
httpGet: | ||
path: '/.well-known/apollo/server-health' | ||
port: http | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 3 | ||
failureThreshold: 5 | ||
readinessProbe: | ||
httpGet: | ||
path: '/.well-known/apollo/server-health' | ||
port: http | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 3 | ||
failureThreshold: 5 | ||
resources: | ||
{{- toYaml .Values.api.resources | nindent 12 }} | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
privileged: false | ||
runAsNonRoot: true | ||
runAsUser: 1000 | ||
runAsGroup: 1000 | ||
capabilities: | ||
drop: | ||
- ALL | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: api | ||
labels: | ||
{{- include "common.labels" . | nindent 4 }} | ||
component: api | ||
annotations: | ||
{{- include "common.annotations" . | nindent 4 }} | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- port: 3000 | ||
targetPort: http | ||
protocol: TCP | ||
name: http-3000 | ||
selector: | ||
component: api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: main | ||
labels: | ||
{{- include "common.labels" . | nindent 4 }} | ||
annotations: | ||
{{- with .Values.ingress.annotations }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- include "common.annotations" . | nindent 4 }} | ||
spec: | ||
ingressClassName: nginx | ||
tls: | ||
- hosts: | ||
- {{ .Values.ingress.domain | quote }} | ||
rules: | ||
- host: {{ .Values.ingress.domain | quote }} | ||
http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: api | ||
port: | ||
name: http-3000 |
Oops, something went wrong.