Skip to content

Commit

Permalink
all pipelines and manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
kinfinity committed Mar 5, 2024
1 parent 4836043 commit ea49887
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/code-build2release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
with:
project_id: ${{ secrets.PROJECT_ID }}
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITYPROVIDER }}
service_account: ${{ secrets.GKE_SA_KEY }}
# service_account: ${{ secrets.GKE_SA_KEY }}

- name: Configure kubectl
uses: google-github-actions/setup-gcloud@v0
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/infra-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Terraform Release Workflow
on:
push:
branches:
- main
pull_request:

env:
AWS_REGION: us-east-2

jobs:
terraform-release:
name: "Terraform Release"
strategy:
matrix:
environment: [DEV]
runs-on: ubuntu-latest
env:
work-environment: $(echo "${{ matrix.environment }}" | tr '[:upper:]' '[:lower:]')
steps:
- uses: actions/checkout@v2

- name: Install Terraform
env:
TERRAFORM_VERSION: "1.1.9"
run: |
tf_version=$TERRAFORM_VERSION
wget https://releases.hashicorp.com/terraform/"$tf_version"/terraform_"$tf_version"_linux_amd64.zip
unzip terraform_"$tf_version"_linux_amd64.zip
sudo mv terraform /usr/local/bin/
- name: Verify Terraform version
run: terraform --version

- name: Authenticate with Google Cloud
uses: google-github-actions/auth@v0
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: <your-project-id>

- name: Configure kubectl
uses: google-github-actions/setup-gcloud@v0
with:
project_id: <your-project-id>
service_account_key: ${{ secrets.GKE_SA_KEY }}
export_default_credentials: true

- name: Terraform Plan
if: ${{ github.event_name == 'pull_request' }}
run: |
chmod +x ci/scripts/*.sh
python ci/scripts/execute-terraform.py --config ci/configs/pipeline-config.json --command plan --env ${{ env.work-environment }}
- name: Terraform Apply
if: ${{ github.event_name != 'pull_request' }}
run: |
chmod +x ci/scripts/*.sh
python ci/scripts/execute-terraform.py --config ci/configs/pipeline-config.json --command apply --env ${{ env.work-environment }}
41 changes: 41 additions & 0 deletions .github/workflows/k8s-apps-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build_Push_App
on:
workflow_dispatch:
pull_request:
branches:
- main

env:
IMAGE_TAG: $(echo ${{ github.sha }} | cut -c1-4)
NODE_VERSION: 20.11.1

jobs:
images:
name: ImageBuild
runs-on: ubuntu-latest
environment: Dev
steps:
- name: Checkout repository
uses: actions/checkout@v4

# https://github.com/google-github-actions/auth
- name: Authenticate with Google Cloud
uses: 'google-github-actions/auth@v2'
with:
project_id: ${{ secrets.PROJECT_ID }}
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITYPROVIDER }}
# service_account: ${{ secrets.GKE_SA_KEY }}

- name: Configure kubectl
uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{ secrets.PROJECT_ID }}
service_account_key: ${{ secrets.GKE_SA_KEY }}
export_default_credentials: true

- name: Build and Push Image
run: |
chmod +x ci/scripts/build-and-push-app.sh
python3 ci/scripts/build-and-push-all.py --config "ci/configs/pipeline-config.json" --gitsha ${{ env.IMAGE_TAG }} --registry gcr.io/${{ secrets.PROJECT_ID }}
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
51 changes: 51 additions & 0 deletions manifests/cohere-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: cohere-app
spec:
replicas: 3
selector:
matchLabels:
app: cohere-app
template:
metadata:
labels:
app: cohere-app
spec:
imagePullSecrets:
- name: gcr-json-key #
containers:
- name: cohere-app-container
image: gcr.io/circular-genius-416217/cohere-app:v1
ports:
- containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
name: cohere-app-service
spec:
selector:
app: cohere-app
ports:
- protocol: TCP
port: 80
targetPort: 3000
type: LoadBalancer
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: cohere-app-ingress
spec:
ingressClassName: "nginx"
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: cohere-app-service
port:
number: 3000
75 changes: 75 additions & 0 deletions manifests/postgress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: postgres-pv
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgres-statefulset
spec:
replicas: 1
serviceName: "postgres"
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:latest
env:
- name: POSTGRES_USER
value: your_username
- name: POSTGRES_PASSWORD
value: your_password
- name: POSTGRES_DB
value: your_database
ports:
- containerPort: 5432
name: postgres
volumeMounts:
- mountPath: "/var/lib/postgresql/data"
name: postgres-storage
volumeClaimTemplates:
- metadata:
name: postgres-storage
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Service
metadata:
name: postgres-service
spec:
selector:
app: postgres
ports:
- protocol: TCP
port: 5432
targetPort: 5432
type: ClusterIP

0 comments on commit ea49887

Please sign in to comment.