-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* core: k8s * bump grace period to 180s * core: graceful shutdown * github action * update apply_infra
- Loading branch information
Showing
8 changed files
with
204 additions
and
15 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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Deploy Core | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: deploy_core | ||
cancel-in-progress: false | ||
|
||
env: | ||
GCLOUD_PROJECT_ID: ${{ secrets.GCLOUD_PROJECT_ID }} | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get short sha | ||
id: short_sha | ||
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
|
||
- name: "Authenticate with Google Cloud" | ||
uses: "google-github-actions/auth@v1" | ||
with: | ||
credentials_json: "${{ secrets.GCLOUD_SA_KEY }}" | ||
|
||
- name: "Set up Cloud SDK" | ||
uses: "google-github-actions/setup-gcloud@v1" | ||
|
||
- name: Install gke-gcloud-auth-plugin | ||
run: | | ||
gcloud components install gke-gcloud-auth-plugin | ||
- name: Setup kubectl | ||
run: | | ||
gcloud container clusters get-credentials dust-kube --region us-central1 | ||
- name: Build the image on Cloud Build | ||
run: | | ||
chmod +x ./k8s/cloud-build.sh | ||
./k8s/cloud-build.sh core | ||
- name: Deploy the image on Kubernetes | ||
run: | | ||
chmod +x ./k8s/deploy-image.sh | ||
./k8s/deploy-image.sh gcr.io/$GCLOUD_PROJECT_ID/core-image:${{ steps.short_sha.outputs.short_sha }} core-deployment | ||
- name: Wait for rollout to complete | ||
run: | | ||
echo "Waiting for rollout to complete (web)" | ||
kubectl rollout status deployment/core-deployment --timeout=10m |
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,12 @@ | ||
FROM rust:1.70.0 as core | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
RUN cargo build --release | ||
|
||
EXPOSE 3001 | ||
|
||
# Set a default command, it will start the API service if no command is provided | ||
CMD ["cargo", "run", "--release", "--bin", "dust-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
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,11 @@ | ||
target | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
.env | ||
.env*.local | ||
|
||
Dockerfile* | ||
.dockerignore |
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,9 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: core-config | ||
data: | ||
DD_ENV: "prod" | ||
DD_SERVICE: "core" | ||
DD_LOGS_INJECTION: "true" | ||
DD_RUNTIME_METRICS_ENABLED: "true" |
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,54 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: core-deployment | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: core | ||
template: | ||
metadata: | ||
labels: | ||
app: core | ||
name: core-pod | ||
admission.datadoghq.com/enabled: "true" | ||
annotations: | ||
ad.datadoghq.com/web.logs: '[{"source": "core","service": "core","tags": ["env:prod"]}]' | ||
spec: | ||
terminationGracePeriodSeconds: 180 | ||
containers: | ||
- name: web | ||
image: gcr.io/or1g1n-186209/core-image:latest | ||
command: ["cargo", "run", "--release", "--bin", "dust-api"] | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 3001 | ||
|
||
envFrom: | ||
- configMapRef: | ||
name: core-config | ||
- secretRef: | ||
name: core-secrets | ||
env: | ||
- name: DD_AGENT_HOST | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: status.hostIP | ||
|
||
volumeMounts: | ||
- name: service-account-volume | ||
mountPath: /etc/service-accounts | ||
|
||
resources: | ||
requests: | ||
cpu: 1000m | ||
memory: 2.5Gi | ||
limits: | ||
cpu: 1000m | ||
memory: 2.5Gi | ||
|
||
volumes: | ||
- name: service-account-volume | ||
secret: | ||
secretName: gcp-service-account-secret |
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,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: core-service | ||
spec: | ||
selector: | ||
app: core | ||
name: core-pod | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 3001 | ||
type: ClusterIP |