https://github.com/dippynark/cicd-demo
CI/CD Demo
https://github.com/dippynark/cicd-demo
Last synced: 5 months ago
JSON representation
CI/CD Demo
- Host: GitHub
- URL: https://github.com/dippynark/cicd-demo
- Owner: dippynark
- Created: 2021-02-23T20:11:55.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-22T13:28:33.000Z (over 5 years ago)
- Last Synced: 2025-10-05T00:44:42.712Z (10 months ago)
- Language: Makefile
- Size: 301 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CI/CD Demo
This is a demo repository to complement my [Kubernetes-Native CI/CD blog
post](https://www.jetstack.io/blog/kubernetes-native-cicd/).
Prerequisites:
- [gcloud](https://cloud.google.com/sdk/docs/install) configured for a GCP account with available
credits (using the [Free Tier](https://cloud.google.com/free) or otherwise)
- kubectl
- Docker
- [Flux](https://toolkit.fluxcd.io/guides/installation/#install-the-flux-cli)
- GitHub user account
- GitHub bot account
- Domain to configure hostnames:
- tekton
- lighthouse
## Setup
We will perform the following steps:
- Provision a GKE cluster suitable for running the [Kubernetes Cluster API Provider
Kubernetes](https://github.com/dippynark/cluster-api-provider-kubernetes)
- This is an experimental infrastructure provider suitable for testing
- Install Flux to sync repository manifests
- Create missing Secrets
- Setup domain
- Setup GitHub webhook
Create GKE cluster:
```sh
# We will use the Kubernetes Cluster API infrastructure provider to provision workload clusters
# https://github.com/dippynark/cluster-api-provider-kubernetes
gcloud container clusters create management \
--image-type=UBUNTU \
--machine-type=n1-standard-2
CLUSTER_CIDR=`gcloud container clusters describe management --format="value(clusterIpv4Cidr)"`
gcloud compute firewall-rules create allow-management-cluster-pods-ipip \
--source-ranges=$CLUSTER_CIDR \
--allow=ipip
kubectl apply -f https://raw.githubusercontent.com/dippynark/cluster-api-provider-kubernetes/v0.3.3/hack/forward-ipencap.yaml
```
Clone this repository and set the following variables:
```sh
GITHUB_OWNER="dippynark"
GITHUB_REPOSITORY="cicd-demo"
# Personal access token for owner account with full `repo` permissions
export GITHUB_TOKEN=""
GITHUB_BOT_USERNAME="dippynark-bot"
GITHUB_BOT_EMAIL="lukeaddison.785@gmail.com"
# Personal access token for bot account with full `repo` permissions
GITHUB_BOT_TOKEN=""
HMAC_TOKEN=$(openssl rand -hex 32)
DOMAIN="dippynark.co.uk"
```
Modify the
[clusters/management/flux-system/cluster-sync.yaml](clusters/management/flux-system/cluster-sync.yaml)
management configuration file as required (i.e. replacing `dippynark/cicd-demo`, `dippynark-bot` and
`dippynark.co.uk` with `$GITHUB_OWNER/$GITHUB_REPOSITORY`, `$GITHUB_BOT_USERNAME` and `$DOMAIN`
respectively.) and update the [OWNERS file](https://www.kubernetes.dev/docs/guide/owners/):
```sh
cat < OWNERS
approvers:
- $GITHUB_OWNER
reviewers:
- $GITHUB_OWNER
EOF
```
Commit the changes, push to the main branch and add the bot account as a collaborator.
Bootstrap the management cluster:
```sh
# This command may fail the first time due to missing CRDs; this is expected
flux bootstrap github \
--owner=$GITHUB_OWNER \
--repository=$GITHUB_REPOSITORY \
--path=clusters/management \
--personal
```
Once Flux has performed its initial sync, create the Git secret for bootstrapping workload clusters:
```sh
kubectl apply -f - <