19 Commits
Author SHA1 Message Date
Dustin Pianalto 3ddd499e58 Update registry
CI / build (push) Has been cancelled
2021-10-05 23:48:51 -08:00
Dustin Pianalto 7eb908b3f7 Build multiarch and auto deploy
CI / build (push) Has been cancelled
2021-10-02 15:33:14 -08:00
Dustin Pianalto bc39045599 Remove auto deploy 2021-10-01 21:00:36 -08:00
Dusty.P 397c244609 Install kubectl
CI / build (push) Has been cancelled
2021-10-01 19:46:09 -08:00
Dustin Pianalto eaa4bfc759 modify apk repositories
CI / build (push) Has been cancelled
2021-10-01 19:19:24 -08:00
Dustin Pianalto 709e03f9c1 Build on self hosted runner
CI / build (push) Has been cancelled
2021-09-30 08:47:05 -08:00
Dustin Pianalto f35f07e35a Build for ARM
CI / build (push) Has been cancelled
2021-09-29 22:09:47 -08:00
Dustin Pianalto 207e34e700 Build for ARM
CI / build (push) Has been cancelled
2021-09-29 22:08:06 -08:00
Dustin Pianalto 6adbbb36b2 Build for ARM
CI / build (push) Has been cancelled
2021-09-29 21:54:23 -08:00
Dustin Pianalto 329afdbe81 Merge branch 'main' of github.com:dustinpianalto/snowflake
CI / build (push) Has been cancelled
2021-09-29 21:43:38 -08:00
Dustin Pianalto 13501567c0 Add image secret 2021-09-29 21:42:49 -08:00
Dusty.P ed626a2dad Update main.yml
CI / build (push) Has been cancelled
2021-09-29 20:53:04 -08:00
Dusty.P 761814ec62 Update main.yml
CI / build (push) Has been cancelled
2021-09-29 20:38:40 -08:00
Dusty.P 2b4b2af16c Update main.yml
CI / build (push) Has been cancelled
2021-09-29 20:35:33 -08:00
Dusty.P e825e2bf3c Update workflow
CI / build (push) Has been cancelled
2021-09-29 20:31:38 -08:00
Dustin Pianalto 5cb476704e Change deployment cluster
CI / build (push) Has been cancelled
2021-07-11 20:27:22 -08:00
Dustin Pianalto 6d81c22842 Change deployment cluster
CI / build (push) Has been cancelled
2021-07-11 20:24:44 -08:00
Dustin Pianalto b0cb481ead Get worker id from env
CI / build (push) Has been cancelled
2021-07-09 01:15:45 -08:00
Dustin Pianalto b7aa0a83aa Update deployment
CI / build (push) Has been cancelled
2021-07-09 01:03:29 -08:00
4 changed files with 73 additions and 40 deletions
+32 -17
View File
@@ -20,30 +20,45 @@ jobs:
- name: Get Version - name: Get Version
id: get_version id: get_version
uses: battila7/get-version-action@v2.0.0 uses: battila7/get-version-action@v2.0.0
- name: Build container image - name: install buildx
env: id: buildx
IMAGE_TAG: ${{ steps.get_version.outputs.version-without-v }} uses: crazy-max/ghaction-docker-buildx@v1
run: docker build -t registry.digitalocean.com/djpianalto/snowflake-server:$IMAGE_TAG .
- name: Install doctl
uses: digitalocean/action-doctl@v2
with: with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} version: latest
- name: Login to DigitalOcean Container Registry with short-lived credentials - name: Docker Login
run: doctl registry login --expiry-seconds 600 # You may pin to the exact commit or the version.
# uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v1.10.0
with:
registry: ${{ secrets.DR_URL }}
# Username used to log against the Docker registry
username: ${{ secrets.DH_USERNAME }}
# Password or personal access token used to log against the Docker registry
password: ${{ secrets.DH_PASSWORD }}
# Log out from the Docker registry at the end of a job
logout: true
- name: Push image to DigitalOcean Container Registry - name: Docker Build & Push
env: env:
IMAGE_TAG: ${{ steps.get_version.outputs.version-without-v }} IMAGE_TAG: ${{ steps.get_version.outputs.version-without-v }}
run: docker push registry.digitalocean.com/djpianalto/snowflake-server:$IMAGE_TAG run: |
docker buildx build --push \
--tag ${{ secrets.DR_URL }}/snowflake-server:$IMAGE_TAG \
--platform linux/amd64,linux/arm/v7,linux/arm64 .
- name: Update deployment file - name: Update deployment file
run: TAG=${{ steps.get_version.outputs.version-without-v }} && sed -i 's|<IMAGE>|registry.digitalocean.com/djpianalto/snowflake-server:'${TAG}'|' $GITHUB_WORKSPACE/deployment.yml run: TAG=${{ steps.get_version.outputs.version-without-v }} && sed -i 's|<IMAGE>|${{ secrets.DR_URL }}/snowflake-server:'${TAG}'|' $GITHUB_WORKSPACE/deployment.yml
- name: Save DigitalOcean kubeconfig with short-lived credentials - uses: azure/k8s-set-context@v1
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 discord-bots with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBE_CONFIG }}
id: setcontext
- name: Deploy to DigitalOcean Kubernetes - name: Deploy to Kubernetes
run: kubectl apply -f $GITHUB_WORKSPACE/deployment.yml run: kubectl apply -f $GITHUB_WORKSPACE/deployment.yml
- name: Verify deployment
run: kubectl rollout status deployment/snowflake-server
+1
View File
@@ -5,6 +5,7 @@ COPY ./go.mod .
COPY ./go.sum . COPY ./go.sum .
RUN go mod download RUN go mod download
RUN sed -i 's/https/http/' /etc/apk/repositories
RUN apk update RUN apk update
RUN apk add protobuf RUN apk add protobuf
+9 -1
View File
@@ -1,6 +1,9 @@
package main package main
import ( import (
"log"
"os"
"strconv"
"sync" "sync"
"github.com/dustinpianalto/snowflake/internal/generator" "github.com/dustinpianalto/snowflake/internal/generator"
@@ -10,7 +13,12 @@ import (
func main() { func main() {
generator.CreateGenerator(1) workerID, err := strconv.ParseUint(os.Getenv("WORKER_ID"), 10, 64)
if err != nil {
log.Fatal("Not a valid worker id")
}
generator.CreateGenerator(workerID)
go generator.Generator.Run() go generator.Generator.Run()
+31 -22
View File
@@ -2,7 +2,7 @@ kind: Service
apiVersion: v1 apiVersion: v1
metadata: metadata:
name: snowflake-server name: snowflake-server
namespace: dca namespace: snowflake
labels: labels:
environment: production environment: production
spec: spec:
@@ -21,30 +21,39 @@ status:
--- ---
apiVersion: v1 apiVersion: apps/v1
apiVersion: batch/v1beta1 kind: Deployment
kind: CronJob
metadata: metadata:
name: snowflake-server name: snowflake-server
namespace: default namespace: snowflake
labels: labels:
app: snowflake-server app: snowflake-server
spec: spec:
schedule: "0 0 * * *" replicas: 1
jobTemplate: selector:
matchLabels:
app: snowflake-server
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
minReadySeconds: 30
template:
metadata:
labels:
app: snowflake-server
spec: spec:
template: containers:
spec: - name: snowflake-server
restartPolicy: "OnFailure" image: <IMAGE>
containers: ports:
- name: snowflake-server - containerPort: 50051
image: <IMAGE> - containerPort: 50052
ports: env:
- containerPort: 50051 - name: WORKER_ID
- containerPort: 50052 valueFrom:
env: secretKeyRef:
- name: WORKER_ID name: snowflake
valueFrom: key: worker_id
secretKeyRef: imagePullSecrets:
name: snowflake - name: registry-1
key: worker_id