Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Last active January 17, 2022 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vfarcic/05ec386c4dfa9ee58479da7e30103ca6 to your computer and use it in GitHub Desktop.
Save vfarcic/05ec386c4dfa9ee58479da7e30103ca6 to your computer and use it in GitHub Desktop.
# Source: https://gist.github.com/05ec386c4dfa9ee58479da7e30103ca6
###########################################
# Shipwright #
# Building Container Images In Kubernetes #
# https://youtu.be/tqsSQTewcwM #
###########################################
# Referenced videos:
# - Kaniko - Building Container Images In Kubernetes Without Docker: https://youtu.be/EgwVQN6GNJg
# - Using Docker Multi-Stage Builds: https://youtu.be/zpkqNPwEzac
# - Tekton vs. Argo Workflows - Kubernetes-Native CI/CD Pipelines: https://youtu.be/dAUpAq7hfeA
#########
# Setup #
#########
# Create a Kubernetes cluster
git repo fork vfarcic/shipwright-demo --clone
cd shipwright-demo
# Feel free to change the value to any other container image registry.
# Please note that if you switch to a different registry, you might need to change the `spec.source.url` field in build.yaml.
export REGISTRY_SERVER=https://index.docker.io/v1/
# Replace `[...]` with the registry user
export REGISTRY_USER=[...]
# Replace `[...]` with the registry password
export REGISTRY_PASS=[...]
# Replace `[...]` with the registry password
export REGISTRY_EMAIL=[...]
# Replace `[...]` with the GitHub username or organization
export GITHUB_ORG=[...]
cat build.yaml \
| sed -e "s@image: .*@image: docker.io/$REGISTRY_USER/devops-toolkit:latest@g" \
| sed -e "s@url: .*@url: https://github.com/$GITHUB_ORG/shipwright-demo@g" \
| tee build.yaml
cat build-run.yaml \
| sed -e "s@image: .*@image: docker.io/$REGISTRY_USER/devops-toolkit:0.0.1@g" \
| tee build-run.yaml
kubectl apply \
--filename https://storage.googleapis.com/tekton-releases/pipeline/previous/v0.25.0/release.yaml
kubectl apply \
--filename https://github.com/shipwright-io/build/releases/download/v0.5.1/release.yaml
kubectl apply \
--filename https://github.com/shipwright-io/build/releases/download/nightly/default_strategies.yaml
kubectl --namespace shipwright-build \
create secret \
docker-registry regcred \
--docker-server=$REGISTRY_SERVER \
--docker-username=$REGISTRY_USER \
--docker-password=$REGISTRY_PASS \
--docker-email=$REGISTRY_EMAIL
cat Dockerfile
####################
# Build Strategies #
####################
kubectl get clusterbuildstrategies
##########
# Builds #
##########
cat build.yaml
kubectl --namespace shipwright-build \
apply --filename build.yaml
cat build-run.yaml
###################
# Building Images #
###################
kubectl --namespace shipwright-build \
create --filename build-run.yaml
kubectl --namespace shipwright-build \
get buildruns
kubectl --namespace shipwright-build \
describe buildrun
# Change the tag `0.0.1` to `0.0.2` in `build-run.yaml`
kubectl --namespace shipwright-build \
create --filename build-run.yaml
kubectl --namespace shipwright-build \
get buildruns
echo https://hub.docker.com/r/$REGISTRY_USER/devops-toolkit/tags
# Open it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment