To fork kubernetes/examples/guestbook-go directory,
git clone https://github.com/kubernetes/examples.git
cd examples
git subtree split --prefix=guestbook-go -b main
git checkout main
# create a GitHub repo
git remote set-url origin YOUR_NEW_GIT_LINK
git fetch -pa
git push -u origin main
# clone the new repo
cd ..
git clone YOUR_NEW_GIT_LINK
cd YOUR_NEW_REPO
Since the forked repo had Apache License 2.0, we persevere the LICENSE
GitHub has some granular and configurable settings to enable branch protection,
Settings:
- [x] Require a pull request before merging
- [x] Require approvals: 1 (testing purpose, do increase if required)
- [x] Dismiss stale pull request approvals when new commits are pushed
- [x] Require review from Code Owners (may include CODEOWNERS file)
- [ ] Do not allow bypassing the above settings (testing purpose)
Requirements:
- Create a container image
- Push that image to DockerHub
- Build container image only when one of the below conditions is true,
- When PR get merged in main/master branch from any other branch
- When commit message contains `BUILD_CONTAINER_IMAGE` string
- To build a container image use docker's build-and-push GitHub action
- Create a token on DockerHub and add credentials to repository secrets. Refer DockerHub Docs
- Add conditionals to action workflow
...
on:
push:
branches: [main]
pull_request:
types:
- closed
branches:
- main
jobs:
build-publish-container-image:
if: github.event.pull_request.merged == true || contains(github.event.head_commit.message, 'BUILD_CONTAINER_IMAGE')
- Install and run
minikube
, Refer Gettting started with minikube.- (Optional, Fedora specific steps) Prefer virtualization over containerization, due to known issues with btrfs and systemd.
sudo dnf install @virtualization sudo systemctl start libvirtd sudo systemctl enable libvirtd # start minikube minikube start --driver kvm2
- Make sure that your image path is correct and pointing to your DockerHub container image in
guestbook-controller.json
,
...
"spec":{
"containers":[
{
"name":"guestbook",
"image":"jayantkatia/actions-for-docker:latest",
...
}
]
}
...
- Run,
kubectl apply -f redis-master-controller.json
kubectl apply -f redis-master-service.json
kubectl apply -f redis-replica-controller.json
kubectl apply -f redis-replica-service.json
kubectl apply -f guestbook-controller.json
kubectl apply -f guestbook-service.json
- Run
minikube tunnel
to allocate an external IP to LoadBalancer.
Yes, please! Feel free to contribute, raise issues and recommend best practices.
A few resources to get you started: