Skip to content

Commit

Permalink
chore(ops): setup basic http deployment via doks
Browse files Browse the repository at this point in the history
  • Loading branch information
zenlex committed Mar 23, 2024
1 parent 733d330 commit 99faa79
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 51 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Install DO CLI
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}

- name: Log in to DigitalOcean Container Registry with short-lived credentials
run: doctl registry login --expiry-seconds 1200

# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
Expand All @@ -56,17 +47,3 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

deploy-to-cluster:
steps:
- name: Update deployment file
run: TAG=$(echo $GITHUB_SHA | head -c7) && sed -i 's|<IMAGE>|${{ secrets.REGISTRY_NAME }}/${{ env.IMAGE_NAME }}:'${TAG}'|' $GITHUB_WORKSPACE/config/deployment.yml

- name: Save DigitalOcean kubeconfig with short-lived credentials
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.CLUSTER_NAME }}

- name: Deploy to DigitalOcean Kubernetes
run: kubectl apply -f $GITHUB_WORKSPACE/config/deployment.yml

- name: Verify deployment
run: kubectl rollout status deployment/${{ env.IMAGE_NAME }}
37 changes: 9 additions & 28 deletions config/deployment.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: services-proposals
labels:
app: services-proposals
name: proposals
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: services-proposals
app: proposals
strategy:
rollingUpdate:
maxSurge: 1
Expand All @@ -17,29 +16,11 @@ spec:
template:
metadata:
labels:
app: services-proposals
app: proposals
spec:
containers:
- name: services-proposals
image: <IMAGE>
ports:
- containerPort: 80
resources:
requests:
cpu: 100m
limits:
cpu: 100m
---
# apiVersion: v1
# kind: Service
# metadata:
# name: services-proposals
# spec:
# type: LoadBalancer
# ports:
# - name: http
# protocol: TCP
# port: 80
# targetPort: 80
# selector:
# app: services-proposals
- name: proposals
image: ghcr.io/tulsawebdevs/services-proposals:release
imagePullPolicy: Always
ports:
- containerPort: 3000
12 changes: 12 additions & 0 deletions config/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: node-service
namespace: default
spec:
type: LoadBalancer
selector:
app: proposals
ports:
- port: 80
targetPort: 3000

0 comments on commit 99faa79

Please sign in to comment.