Coder Social home page Coder Social logo

local-k8s-demo's Introduction

aholten's local k8s demo repo

As part of learning Kubernetes and studying for the CKAD exam, I configured k8s locally on my machine using this set up. The specific goal I had in mind was to deploy a containerized HTTP server program and expose it to the web from my local machine. The tools I'm using here are just one way to accomplish this goal, but it should be simple enough to follow along and is totally free, though you may need to make an account to use ngrok.

For reference, my machines use Apple Silicon chips (an M1 MacBook Pro and an M2 Mac Mini).

Setup

First, let's install the tools we will be using: Docker, Minikube, and ngrok.

Mac Instructions

If you have Homebrew already installed on your Mac, just run the included bash script brew_installer.sh. This installs all three components.

Other OS Instructions

First Time Deployment

  • Start Docker Desktop
  • Run build_and_deploy.sh
    (you should see something like this)
    ๐Ÿ˜„  minikube v1.31.2 on Darwin 13.5.1 (arm64)
    โœจ  Automatically selected the docker driver
    ๐Ÿ“Œ  Using Docker Desktop driver with root privileges
    ๐Ÿ‘  Starting control plane node minikube in cluster minikube
    ๐Ÿšœ  Pulling base image ...
    ๐Ÿ’พ  Downloading Kubernetes v1.27.4 preload ...
        > preloaded-images-k8s-v18-v1...:  327.74 MiB / 327.74 MiB  100.00% 2.11 Mi
        > gcr.io/k8s-minikube/kicbase...:  404.50 MiB / 404.50 MiB  100.00% 2.44 Mi
    ๐Ÿ”ฅ  Creating docker container (CPUs=2, Memory=4000MB) ...
    ๐Ÿณ  Preparing Kubernetes v1.27.4 on Docker 24.0.4 ...
        โ–ช Generating certificates and keys ...
        โ–ช Booting up control plane ...
        โ–ช Configuring RBAC rules ...
    ๐Ÿ”—  Configuring bridge CNI (Container Networking Interface) ...
        โ–ช Using image gcr.io/k8s-minikube/storage-provisioner:v5
    ๐Ÿ”Ž  Verifying Kubernetes components...
    ๐ŸŒŸ  Enabled addons: storage-provisioner
    ๐Ÿ„  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
    [+] Building 18.9s (8/8) FINISHED                                                                                                 docker:default
    => [internal] load build definition from Dockerfile        0.0s
    => => transferring dockerfile: 133B                         0.0s
    => [internal] load .dockerignore                            0.0s
    => => transferring context: 2B                              0.0s
    => [internal] load metadata for docker.io/oven/bun:1.0.3     1.2s
    => [1/3] FROM docker.io/oven/bun:1.0.....
    
    What's Next?
    View a summary of image vulnerabilities and recommendations โ†’ docker scout quickview
    deployment.apps/bun-http-server created
    service/bun-http-server created
    pod/bun-http-server-6cf795c4d-g2wln condition met
    pod/bun-http-server-6cf795c4d-s54k6 condition met
    Forwarding from 127.0.0.1:3000 -> 3000
    Forwarding from [::1]:3000 -> 3000
    
  • You can now access the http server at localhost:3000 !!!

    • It should say You just deployed an HTTP server to the web with k8s!
  • If you want to expose your local server to the open web:

    • Open a new terminal window, as kubectl will be using the previous one
    • Provide ngrok with your user token: ngrok config add-authtoken <YOUR_AUTHTOKEN>
    • run expose.sh
    • The k8s cluster running on your local machine now is exposed to the world wide web with the forwarding URL from ngrok!
  • You're now free to break things and tinker with the k8s environment. Let me know if you run into any issues.

local-k8s-demo's People

Contributors

aholten avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.