Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Last active December 31, 2021 16:03
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 vfarcic/6039be2497217a555fba5eafea076ba3 to your computer and use it in GitHub Desktop.
Save vfarcic/6039be2497217a555fba5eafea076ba3 to your computer and use it in GitHub Desktop.
# Source: https://gist.github.com/6039be2497217a555fba5eafea076ba3
#########################################################################
# Werf: Glue Together Git, Docker, Helm, Kubernetes For CI/CD Pipelines #
# https://youtu.be/WM06S_ltcVs #
#########################################################################
# Additional Info:
# - werf: https://werf.io
# - GitHub CLI - How to manage repositories more efficiently: https://youtu.be/BII6ZY2Rnlc
#########
# Setup #
#########
# Watch https://youtu.be/BII6ZY2Rnlc if you are not familiar with GitHub CLI
gh repo fork vfarcic/werf-demo --clone
cd werf-demo
# Create a Kubernetes cluster
# Using Rancher Desktop for the demo, but it can be any other Kubernetes cluster with Ingress
# If not using Rancher Desktop, replace `127.0.0.1` with the base host accessible through NGINX Ingress
export INGRESS_HOST=127.0.0.1
cat .helm/templates/003-ingress.yaml \
| sed "s@host: .*@host: devops-toolkit.$INGRESS_HOST.nip.io@g" \
| tee .helm/templates/003-ingress.yaml
git add .
git commit -m "Host"
git push
curl -sSLO https://werf.io/install.sh
chmod +x install.sh
./install.sh \
--version 1.2 \
--channel stable
# Follow the instructions from the output
# Replace `[...]` with your Docker Hub user
export DH_USER=[...]
#####################################
# Build, Push, And Deploy With werf #
#####################################
werf converge \
--repo $DH_USER/werf-demo \
--platform linux/amd64
helm --namespace werf-demo ls
echo "https://hub.docker.com/r/$DH_USER/werf-demo"
# Open it in a browser
kubectl --namespace werf-demo \
get all,ingresses
echo "http://devops-toolkit.$INGRESS_HOST.nip.io"
# Open it in a browser
##################################
# Upgrade Applications With werf #
##################################
# Open `frontend/config.toml` in an editor and change `The DevOps Toolkit Series` to `Should We Use werf?`
werf converge \
--repo $DH_USER/werf-demo \
--platform linux/amd64
git add .
git commit -m "New release"
git push
werf converge \
--repo $DH_USER/werf-demo \
--platform linux/amd64
####################
# werf Definitions #
####################
# Refresh the app in browser
cat werf.yaml
cat frontend/Dockerfile
cat backend/Dockerfile
ls -1 .helm/
ls -1 .helm/templates/
cat .helm/templates/001-frontend.yaml
#####################################
# Deploying To Production With werf #
#####################################
werf converge \
--repo $DH_USER/werf-demo \
--platform linux/amd64 \
--env production
#######################
# Other werf Features #
#######################
werf dismiss --with-namespace
kubectl get namespaces
werf build ...
werf run ...
###############################
# Doing The Same Without Werf #
###############################
docker image build ...
docker image push ...
helm upgrade --install --set image.tag=...
###########
# Destroy #
###########
cat frontend/config.toml \
| sed -e "s@Should We Use werf?@The DevOps Toolkit Series@g" \
| tee frontend/config.toml
git add .
git commit -m "Revert"
git push
# Destroy or reset the cluster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment