-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* gke deployment added * variable update * kustomize build fixed * deploy step fixed * deploy step kustomize update * deployment.yaml updated
- Loading branch information
1 parent
1f406af
commit 2c88977
Showing
5 changed files
with
95 additions
and
20 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea | ||
.git | ||
|
||
.github | ||
.kubernetes |
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,74 @@ | ||
name: Build and Deploy to GKE | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+*' | ||
|
||
env: | ||
PROJECT_ID: ${{ secrets.GKE_PROJECT }} | ||
GKE_CLUSTER: pulsey-cluster-1 | ||
GKE_ZONE: europe-west3-a | ||
DEPLOYMENT_NAME: game-server | ||
IMAGE: game-server | ||
|
||
jobs: | ||
build-and-deploy: | ||
name: Build and Deploy | ||
runs-on: ubuntu-latest | ||
environment: production | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
# Get git tags | ||
- name: Get Version | ||
id: vars | ||
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:10}) | ||
|
||
# Setup gcloud CLI | ||
- uses: google-github-actions/[email protected] | ||
with: | ||
service_account_key: ${{ secrets.GKE_SA_KEY }} | ||
project_id: ${{ secrets.GKE_PROJECT }} | ||
|
||
# Configure Docker to use the gcloud command-line tool as a credential | ||
# helper for authentication | ||
- run: |- | ||
gcloud --quiet auth configure-docker | ||
# Get the GKE credentials so we can deploy to the cluster | ||
- uses: google-github-actions/[email protected] | ||
with: | ||
cluster_name: ${{ env.GKE_CLUSTER }} | ||
location: ${{ env.GKE_ZONE }} | ||
credentials: ${{ secrets.GKE_SA_KEY }} | ||
|
||
# Build the Docker image | ||
- name: Build | ||
run: |- | ||
docker build \ | ||
--tag "gcr.io/$PROJECT_ID/$IMAGE:${{ steps.vars.outputs.tag }}" \ | ||
. | ||
# Push the Docker image to Google Container Registry | ||
- name: Publish | ||
run: |- | ||
docker push "gcr.io/$PROJECT_ID/$IMAGE:${{ steps.vars.outputs.tag }}" | ||
# Set up kustomize | ||
- name: Set up Kustomize | ||
run: |- | ||
curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64 | ||
chmod u+x ./kustomize | ||
# Deploy the Docker image to the GKE cluster | ||
- name: Deploy | ||
run: |- | ||
cd .kubernetes | ||
../kustomize edit set image gcr.io/PROJECT_ID/IMAGE:TAG=gcr.io/$PROJECT_ID/$IMAGE:${{ steps.vars.outputs.tag }} | ||
../kustomize build . | kubectl apply -f - | ||
kubectl rollout status deployment/$DEPLOYMENT_NAME | ||
kubectl get services -o wide |
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,5 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- deployment.yaml | ||
- service.yaml |
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 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: game-server-service | ||
spec: | ||
type: LoadBalancer | ||
ports: | ||
- protocol: TCP | ||
port: 3000 | ||
targetPort: 3000 | ||
selector: | ||
app: game-server |