Skip to content

Instantly share code, notes, and snippets.

@heartshare
Forked from mkhmylife/laravel-k8s-gitlab-ci.yml
Created October 17, 2022 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heartshare/88ad3194aaa18399098b8a90283e304f to your computer and use it in GitHub Desktop.
Save heartshare/88ad3194aaa18399098b8a90283e304f to your computer and use it in GitHub Desktop.
variables:
DOCKER_DRIVER: "overlay2"
REPOSITORY_URL: "changeme:latest"
stages:
- build
- deploy
services:
- docker:dind
build-app:
stage: build
only:
- master
script:
- mkdir -p $HOME/.docker
- apk add --no-cache curl jq python py-pip
- pip install awscli
- $(aws ecr get-login --no-include-email --region ap-southeast-1)
- docker info
- docker build -t ${REPOSITORY_URL} .
- docker push ${REPOSITORY_URL}
deploy-app:
stage: deploy
image: alpine
only:
- master
script:
- apk add --no-cache curl
- curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
- chmod +x ./kubectl
- mv ./kubectl /usr/local/bin/kubectl
- kubectl config set-cluster k8s --server="$KUBE_URL" --insecure-skip-tls-verify=true
- kubectl config set-credentials admin --token="$KUBE_TOKEN"
- kubectl config set-context default --cluster=k8s --user=admin
- kubectl config use-context default
- cd k8s && kubectl apply -f -
- kubectl patch deployment backend -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\":\"`date +'%s'`\"}}}}}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment