Skip to content

ggerritsen/kubernetes-tryout

Repository files navigation

K8s try out repo 2020

How to run locally

  1. cd api && go run main.go
  2. cd customersvc && go run main.go
  3. cd greetsvc && go run main.go

How to run 1 docker container locally

  1. docker run -t -d <image>

How to run locally with docker-compose

  1. docker-compose up
    Check with:
  • docker exec -it <container> /bin/bash

How to start a k3s cluster

  1. wget -q -O - https://raw.githubusercontent.com/rancher/k3d/master/install.sh | TAG=v1.7.0 bash to install k3d
  2. k3d create --api-port 6550 --publish 8090:80 --workers 3 # 80 is the ingress port that traefik listens on
  3. export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"
  4. kubectl cluster-info
  5. kubectl get all -o wide
  6. For login credentials, see cat $KUBECONFIG

How to deploy to k3s

  1. Make sure latest images have been built: docker-compose build
  2. And have been tagged: docker tag k8s-tryout-2020_api:latest ggerritsen1/k8s-tryout-2020_api:latest
  3. And have been pushed: docker push ggerritsen1/k8s-tryout-2020_api:latest

Then:

  1. kubectl apply -f api-deployment.yaml
    Check with:
  • kubectl get pods -o wide
  • kubectl logs -f -lapp=k8s-tryout-2020-frontend --all-containers=true --max-log-requests=10
  • kubectl logs -f -lapp=k8s-tryout-2020-backend --all-containers=true
  1. Open http://api.localhost:8090/hello to see that it works

Troubleshoot

  1. Run bash on a specific container kubectl exec -it pod/k8s-tryout-2020-api-deployment-54d587f5bf-qqpwv -- /bin/bash
  2. Run bash on a helper container kubectl --namespace=default run -it --image=alpine helper-container, then wget -SO- k8s-tryout-2020-api/hello
  3. See traefik dashboard:
  • kubectl -n kube-system edit configmap traefik, then add:
  [api]
      dashboard = true 

Next steps

  • Make smaller containers (from scratch)
  • Try https://k8slens.dev/
  • Add a database
  • Add integration with an external endpoint/system
Sources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published