Skip to content

Commit

Permalink
added base k8s deployment
Browse files Browse the repository at this point in the history
added pipeline
added brew.sh script
added concurrency to all pipelines
  • Loading branch information
rotarur committed Jul 27, 2023
1 parent 02fc06c commit 1c69ca3
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .github/workflows/cd-testnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Testnet CD for graphix

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

on:
workflow_dispatch:
pull_request:

jobs:
deploy:
uses: ./.github/workflows/template-deploy.yaml
with:
ENVIRONMENT: testnet
secrets:
GCP_SECRET: ${{ secrets.GCP_GRAPH_NETWORK }}
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: CI pipeline

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

on:
push:
branches: [main]
Expand Down Expand Up @@ -34,7 +38,7 @@ jobs:
args: --all -- --check

docker-api-server:
runs-on: ubuntu-latest
runs-on: ubuntu-latest/Users/rotarur/projects/edgeandnode/graph-infra/.github/workflows/template-deploy.yaml
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/template-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Template Deploy

on:
workflow_call:
inputs:
GCP_PROJECT_ID:
required: false
type: string
default: graph-mainnet
CLUSTER_NAME:
required: false
type: string
default: testnet
CLUSTER_LOCATION:
required: false
type: string
default: us-central1-a
ENVIRONMENT:
required: false
type: string
default: testnet
ENABLE_DIFF:
required: false
type: boolean
default: true
ENABLE_APPLY:
required: false
type: boolean
default: false
secrets:
GCP_SECRET:
required: true

jobs:
template-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v3

- id: "auth"
uses: "google-github-actions/auth@v1"
with:
credentials_json: ${{ secrets.GCP_SECRET }}

- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{ inputs.GCP_PROJECT_ID }}

- id: "get-credentials"
uses: "google-github-actions/get-gke-credentials@v1"
with:
cluster_name: ${{ inputs.CLUSTER_NAME }}
location: ${{ inputs.CLUSTER_LOCATION }}

- name: Enable homebrew
uses: raviqqe/[email protected]

- name: Install infrastructure tools
run: ./brew.sh

- name: Diff ${{ inputs.ENVIRONMENT }}
if: inputs.ENABLE_DIFF
working-directory: k8s
run: kubectl diff -k ${{ inputs.ENVIRONMENT }}

- name: Deploy to ${{ inputs.ENVIRONMENT }} cluster
if: inputs.ENABLE_APPLY
working-directory: k8s
run: kubectl apply -k ${{ inputs.ENVIRONMENT }}
8 changes: 8 additions & 0 deletions brew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

brew install cask google-cloud-sdk
gcloud components install gke-gcloud-auth-plugin

curl -LO "https://dl.k8s.io/release/v1.24.1/bin/linux/amd64/kubectl"
chmod +x ./kubectl
mv ./kubectl /usr/local/bin/kubectl
34 changes: 34 additions & 0 deletions k8s/base/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: graphix
labels:
app: graphix
spec:
replicas: 1
selector:
matchLabels:
app: graphix
template:
metadata:
labels:
app: graphix
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
prometheus.io/port: "7300"
spec:
imagePullSecrets:
- name: docker-registry
containers:
- name: graphix
image: graphix:to-be-replaced-by-kustomize
imagePullPolicy: IfNotPresent
ports:
- name: graphix
containerPort: 80
- name: metrics
containerPort: 7300
command:
- sleep
- infinte
8 changes: 8 additions & 0 deletions k8s/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- deployment.yaml
# - service.yaml
# - ingress.yaml
# - servicemonitor.yaml
10 changes: 10 additions & 0 deletions k8s/testnet/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

bases:
- ../base

images:
- name: graphix
newName: ghcr.io/edgeandnode/graphix-cross-checker
newTag: latest

0 comments on commit 1c69ca3

Please sign in to comment.