Skip to content

Instantly share code, notes, and snippets.

@davidalger
Forked from kevin-smets/1_kubernetes_on_macOS.md
Created September 18, 2018 17:59
Show Gist options
  • Select an option

  • Save davidalger/24e7a7a2f15790933a2935d7c741128f to your computer and use it in GitHub Desktop.

Select an option

Save davidalger/24e7a7a2f15790933a2935d7c741128f to your computer and use it in GitHub Desktop.

Revisions

  1. @kevin-smets kevin-smets revised this gist Jun 21, 2018. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions 1_kubernetes_on_macOS.md
    Original file line number Diff line number Diff line change
    @@ -49,9 +49,13 @@ Should output something like:

    eval $(minikube docker-env)

    Add this line to `.bash_profile` or `.zshrc` or ... if you do not want to run this every time you open a new terminal.
    Add this line to `.bash_profile` or `.zshrc` or ... if you want to use minikube's daemon by default (or if you do not want to set this every time you open a new terminal).

    You can revert back to the host docker daemon by running:

    eval $(docker-machine env -u)

    Running `docker ps` should now output something like:
    If you now run `docker ps`, it should now output something like:

    ```
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  2. @kevin-smets kevin-smets revised this gist Jun 21, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions 1_kubernetes_on_macOS.md
    Original file line number Diff line number Diff line change
    @@ -49,6 +49,8 @@ Should output something like:

    eval $(minikube docker-env)

    Add this line to `.bash_profile` or `.zshrc` or ... if you do not want to run this every time you open a new terminal.

    Running `docker ps` should now output something like:

    ```
  3. @kevin-smets kevin-smets revised this gist Jan 22, 2018. 1 changed file with 0 additions and 4 deletions.
    4 changes: 0 additions & 4 deletions 1_kubernetes_on_macOS.md
    Original file line number Diff line number Diff line change
    @@ -118,10 +118,6 @@ You're now good to go and deploy other images!
    rm -rf ~/.minikube .kube;
    brew uninstall kubectl;
    brew cask uninstall docker virtualbox minikube;

    # TODO

    Will try to convert this to xhyve when possible.˜˜

    # Version

  4. @kevin-smets kevin-smets revised this gist Jan 22, 2018. No changes.
  5. @kevin-smets kevin-smets revised this gist Jan 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 1_kubernetes_on_macOS.md
    Original file line number Diff line number Diff line change
    @@ -121,7 +121,7 @@ You're now good to go and deploy other images!

    # TODO

    Will try to convert this to xhyve when possible.
    Will try to convert this to xhyve when possible.˜˜

    # Version

  6. @kevin-smets kevin-smets revised this gist Oct 23, 2017. No changes.
  7. @kevin-smets kevin-smets revised this gist Oct 23, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion my-app.yml
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ spec:
    run: my-app-exposed
    spec:
    containers:
    - image: localhost:5000/my-app:0.0.1
    - image: localhost:5000/my-app:0.1.0
    name: my-app
    ports:
    - containerPort: 80
  8. @kevin-smets kevin-smets revised this gist Oct 20, 2017. 4 changed files with 21 additions and 18 deletions.
    28 changes: 15 additions & 13 deletions 1_kubernetes_on_macOS.md
    Original file line number Diff line number Diff line change
    @@ -19,11 +19,11 @@ brew update && brew install kubectl && brew cask install docker minikube virtual

    # Verify

    docker --version # Docker version 17.06.0-ce, build 02c1d87
    docker-compose --version # docker-compose version 1.14.0, build c7bdf9e
    docker-machine --version # docker-machine version 0.12.0, build 45c69ad
    minikube version # minikube version: v0.21.0
    kubectl version --client # Client Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.3", GitCommit:"2c2fe6e8278a5db2d15a013987b53968c743f2a1", GitTreeState:"clean", BuildDate:"2017-08-03T15:13:53Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"darwin/amd64"}
    docker --version # Docker version 17.09.0-ce, build afdb6d4
    docker-compose --version # docker-compose version 1.16.1, build 6d1ac21
    docker-machine --version # docker-machine version 0.12.2, build 9371605
    minikube version # minikube version: v0.22.3
    kubectl version --client # Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.1", GitCommit:"f38e43b221d08850172a9a4ea785a86a3ffa3b3a", GitTreeState:"clean", BuildDate:"2017-10-12T00:45:05Z", GoVersion:"go1.9.1", Compiler:"gc", Platform:"darwin/amd64"}

    # Start

    @@ -42,8 +42,8 @@ Great! You now have a running Kubernetes cluster locally. Minikube started a vir

    Should output something like:

    NAME STATUS AGE VERSION
    minikube Ready 9s v1.7.0
    NAME STATUS ROLES AGE VERSION
    minikube Ready <none> 40s v1.7.5

    # Use minikube's built-in docker daemon:

    @@ -65,21 +65,23 @@ First setup a local registry, so Kubernetes can pull the image(s) from there:

    ## Build

    First of, store all files (Dockerfile, my-app.yml, index.html) in this gist locally in some new (empty) directory.

    You can build the Dockerfile below locally if you want to follow this guide to the letter. Store the Dockerfile locally, preferably in an empty directory and run:

    docker build . --tag my-app

    You should now have an image named 'my-app' locally, check by using `docker images` (or your own image of course). You can then publish it to your local docker registry:

    docker tag my-app localhost:5000/my-app:0.0.1
    docker tag my-app localhost:5000/my-app:0.1.0

    Running `docker images` should now output the following:

    ```
    REPOSITORY TAG IMAGE ID CREATED SIZE
    node 8-alpine 442930c9c9fb 2 weeks ago 64.6MB
    localhost:5000/my-app latest 442930c9c9fb 2 weeks ago 64.6MB
    my-app latest 442930c9c9fb 2 weeks ago 64.6MB
    my-app latest cc949ad8c8d3 44 seconds ago 89.3MB
    localhost:5000/my-app 0.1.0 cc949ad8c8d3 44 seconds ago 89.3MB
    httpd 2.4-alpine fe26194c0b94 7 days ago 89.3MB
    ```

    ## Deploy and run
    @@ -96,7 +98,7 @@ The configuration exposes `my-app` outside of the cluster, you can get the addre

    minikube service my-app --url

    This should give an output like `http://192.168.99.100:30304` (the port will most likely differ).
    This should give an output like `http://192.168.99.100:30304` (the port will most likely differ). Go there with your favorite browser, you should see "Hello world!". You just accessed your application from outside of your local Kubernetes cluster!

    # Kubernetes GUI

    @@ -123,5 +125,5 @@ Will try to convert this to xhyve when possible.

    # Version

    Last tested on 2017 August 10
    Last tested on 2017 October 20th
    macOS Sierra 10.12.6
    4 changes: 2 additions & 2 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Just for demo purposes obviously
    FROM node:8-alpine
    FROM httpd:2.4-alpine

    CMD tail -f /dev/null
    COPY ./index.html /usr/local/apache2/htdocs/
    1 change: 1 addition & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    Hello world!
    6 changes: 3 additions & 3 deletions my-app.yml
    Original file line number Diff line number Diff line change
    @@ -10,11 +10,11 @@ spec:
    replicas: 1
    selector:
    matchLabels:
    run: my-app
    run: my-app-exposed
    template:
    metadata:
    labels:
    run: my-app-exposed # must match the selector in the service
    run: my-app-exposed
    spec:
    containers:
    - image: localhost:5000/my-app:0.0.1
    @@ -39,5 +39,5 @@ spec:
    protocol: TCP
    targetPort: 80
    selector:
    run: my-app-exposed # must match the label of the pod, otherwise it will not be exposed
    run: my-app-exposed
    type: NodePort
  9. @kevin-smets kevin-smets revised this gist Aug 20, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 1_kubernetes_on_macOS.md
    Original file line number Diff line number Diff line change
    @@ -82,7 +82,7 @@ localhost:5000/my-app latest 44293
    my-app latest 442930c9c9fb 2 weeks ago 64.6MB
    ```

    ## Deploy an run
    ## Deploy and run

    Store the file below `my-app.yml` on your system and run the following:

  10. @kevin-smets kevin-smets revised this gist Aug 10, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions my-app.yml
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ spec:
    template:
    metadata:
    labels:
    run: my-app
    run: my-app-exposed # must match the selector in the service
    spec:
    containers:
    - image: localhost:5000/my-app:0.0.1
    @@ -39,5 +39,5 @@ spec:
    protocol: TCP
    targetPort: 80
    selector:
    run: app-frontend
    run: my-app-exposed # must match the label of the pod, otherwise it will not be exposed
    type: NodePort
  11. @kevin-smets kevin-smets revised this gist Aug 10, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 1_kubernetes_on_macOS.md
    Original file line number Diff line number Diff line change
    @@ -123,5 +123,5 @@ Will try to convert this to xhyve when possible.

    # Version

    Last tested on 2017 August 10
    Last tested on 2017 August 10
    macOS Sierra 10.12.6
  12. @kevin-smets kevin-smets renamed this gist Aug 10, 2017. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions _kubernetes_on_macOS.md → 1_kubernetes_on_macOS.md
    Original file line number Diff line number Diff line change
    @@ -57,12 +57,14 @@ e97128790bf9 gcr.io/google-containers/kube-addon-manager "/opt/kube-add
    69707e54d1d0 gcr.io/google_containers/pause-amd64:3.0 "/pause" 33 seconds ago Up 33 seconds k8s_POD_kube-addon-manager-minikube_kube-system_c654b2f084cf26941c334a2c3d6db53d_0
    ```

    # Deploy and run an image on your local k8s setup
    # Build, deploy and run an image on your local k8s setup

    First setup a local registry, so Kubernetes can pull the image(s) from there:

    docker run -d -p 5000:5000 --restart=always --name registry registry:2


    ## Build

    You can build the Dockerfile below locally if you want to follow this guide to the letter. Store the Dockerfile locally, preferably in an empty directory and run:

    docker build . --tag my-app
    @@ -71,7 +73,7 @@ You should now have an image named 'my-app' locally, check by using `docker imag

    docker tag my-app localhost:5000/my-app:0.0.1

    Runnig `docker images` should now output the following:
    Running `docker images` should now output the following:

    ```
    REPOSITORY TAG IMAGE ID CREATED SIZE
    @@ -80,6 +82,8 @@ localhost:5000/my-app latest 44293
    my-app latest 442930c9c9fb 2 weeks ago 64.6MB
    ```

    ## Deploy an run

    Store the file below `my-app.yml` on your system and run the following:

    kubectl create -f my-app.yml
  13. @kevin-smets kevin-smets revised this gist Aug 10, 2017. 3 changed files with 127 additions and 106 deletions.
    4 changes: 4 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    # Just for demo purposes obviously
    FROM node:8-alpine

    CMD tail -f /dev/null
    123 changes: 123 additions & 0 deletions _kubernetes_on_macOS.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,123 @@
    # Requirements

    Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

    sysctl -a | grep machdep.cpu.features | grep VMX

    If there's output, you're good!

    # Prerequisites

    - kubectl
    - docker (for Mac)
    - minikube
    - virtualbox

    ```
    brew update && brew install kubectl && brew cask install docker minikube virtualbox
    ```

    # Verify

    docker --version # Docker version 17.06.0-ce, build 02c1d87
    docker-compose --version # docker-compose version 1.14.0, build c7bdf9e
    docker-machine --version # docker-machine version 0.12.0, build 45c69ad
    minikube version # minikube version: v0.21.0
    kubectl version --client # Client Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.3", GitCommit:"2c2fe6e8278a5db2d15a013987b53968c743f2a1", GitTreeState:"clean", BuildDate:"2017-08-03T15:13:53Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"darwin/amd64"}

    # Start

    minikube start

    This can take a while, expected output:

    Starting local Kubernetes cluster...
    Kubectl is now configured to use the cluster.

    Great! You now have a running Kubernetes cluster locally. Minikube started a virtual machine for you, and a Kubernetes cluster is now running in that VM.

    # Check k8s

    kubectl get nodes

    Should output something like:

    NAME STATUS AGE VERSION
    minikube Ready 9s v1.7.0

    # Use minikube's built-in docker daemon:

    eval $(minikube docker-env)

    Running `docker ps` should now output something like:

    ```
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    e97128790bf9 gcr.io/google-containers/kube-addon-manager "/opt/kube-addons.sh" 22 seconds ago Up 22 seconds k8s_kube-addon-manager_kube-addon-manager-minikube_kube-system_c654b2f084cf26941c334a2c3d6db53d_0
    69707e54d1d0 gcr.io/google_containers/pause-amd64:3.0 "/pause" 33 seconds ago Up 33 seconds k8s_POD_kube-addon-manager-minikube_kube-system_c654b2f084cf26941c334a2c3d6db53d_0
    ```

    # Deploy and run an image on your local k8s setup

    First setup a local registry, so Kubernetes can pull the image(s) from there:

    docker run -d -p 5000:5000 --restart=always --name registry registry:2

    You can build the Dockerfile below locally if you want to follow this guide to the letter. Store the Dockerfile locally, preferably in an empty directory and run:

    docker build . --tag my-app

    You should now have an image named 'my-app' locally, check by using `docker images` (or your own image of course). You can then publish it to your local docker registry:

    docker tag my-app localhost:5000/my-app:0.0.1

    Runnig `docker images` should now output the following:

    ```
    REPOSITORY TAG IMAGE ID CREATED SIZE
    node 8-alpine 442930c9c9fb 2 weeks ago 64.6MB
    localhost:5000/my-app latest 442930c9c9fb 2 weeks ago 64.6MB
    my-app latest 442930c9c9fb 2 weeks ago 64.6MB
    ```

    Store the file below `my-app.yml` on your system and run the following:

    kubectl create -f my-app.yml

    You should now see your pod and your service:

    kubectl get all

    The configuration exposes `my-app` outside of the cluster, you can get the address to access it by running:

    minikube service my-app --url

    This should give an output like `http://192.168.99.100:30304` (the port will most likely differ).

    # Kubernetes GUI

    minikube dashboard

    # Delete deployment of my-app

    kubectl delete deploy my-app
    kubectl delete service my-app

    You're now good to go and deploy other images!

    # Reset everything

    minikube stop;
    minikube delete;
    rm -rf ~/.minikube .kube;
    brew uninstall kubectl;
    brew cask uninstall docker virtualbox minikube;

    # TODO

    Will try to convert this to xhyve when possible.

    # Version

    Last tested on 2017 August 10
    macOS Sierra 10.12.6
    106 changes: 0 additions & 106 deletions kubernetes_on_macOS.md
    Original file line number Diff line number Diff line change
    @@ -1,106 +0,0 @@
    # Requirements

    Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

    sysctl -a | grep machdep.cpu.features | grep VMX

    If there's output, you're good!

    # Prerequisites

    - kubectl
    - docker (for Mac)
    - minikube
    - virtualbox

    ```
    brew update && brew install kubectl && brew cask install docker minikube virtualbox
    ```

    # Verify

    docker --version # Docker version 1.12.3, build 6b644ec
    docker-compose --version # docker-machine version 0.8.2, build e18a919
    docker-machine --version # docker-compose version 1.8.1, build 878cff1
    minikube version # minikube version: v0.12.2
    kubectl version --client # Client Version: version.Info{Major:"1", Minor:"4", GitVersion:"v1.4.6+e569a27", GitCommit:"e569a27d02001e343cb68086bc06d47804f62af6", GitTreeState:"not a git tree", BuildDate:"2016-11-12T09:26:56Z", GoVersion:"go1.7.3", Compiler:"gc", Platform:"darwin/amd64"}

    # Start

    minikube start

    This can take a while, expected output:

    Starting local Kubernetes cluster...
    Kubectl is now configured to use the cluster.

    Great! You now have a running Kubernetes cluster locally. Minikube started a virtual machine for you, and a Kubernetes cluster is now running in that VM.

    # Check k8s

    kubectl get nodes

    Should output something like:

    NAME STATUS AGE
    minikube Ready 8m

    # Use minikube's built-in docker daemon:

    eval $(minikube docker-env)

    Running `docker ps` should now output something like:

    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    474eae7e7dd4 gcr.io/google_containers/kubernetes-dashboard-amd64:v1.4.0 "/dashboard --port=90" 35 minutes ago Up 35 minutes k8s_kubernetes-dashboard.bdfedaad_kubernetes-dashboard-46007_kube-system_92b679ab-982b-11e6-8ad0-c604d62c2a3b_2afa3feb
    6142f91d57ab gcr.io/google_containers/pause-amd64:3.0 "/pause" 35 minutes ago Up 35 minutes k8s_POD.2225036b_kubernetes-dashboard-46007_kube-system_92b679ab-982b-11e6-8ad0-c604d62c2a3b_61445f01
    332c645bb167 gcr.io/google-containers/kube-addon-manager:v5.1 "/opt/kube-addons.sh" 35 minutes ago Up 35 minutes k8s_kube-addon-manager.92e38b3b_kube-addon-manager-minikube_kube-system_46ae05e07c52d84167b077b142aa4a39_253f9280
    8ea2cd68e0a8 gcr.io/google_containers/pause-amd64:3.0 "/pause" 35 minutes ago Up 35 minutes k8s_POD.d8dbe16c_kube-addon-manager-minikube_kube-system_46ae05e07c52d84167b077b142aa4a39_da8bd6f9

    # Deploy and run an image on your local k8s setup

    First setup a local registry, so Kubernetes can pull the image(s) from there:

    docker run -d -p 5000:5000 --restart=always --name registry registry:2

    If you have already built an image, e.g. named 'my-app' locally (check by using `docker images`), you can publish it to your local repo:

    docker tag my-app localhost:5000/my-app

    Check the two yaml files, and run the following:

    kubectl create -f my-app.yml

    You should now see your pod and your service:

    kubectl get all

    The configuration exposes `my-app` outside of the cluster, you can get the address to access it by running:

    minikube service my-app --url

    This should give an output like `http://192.168.99.100:30304` (the port will most likely differ).

    # Kubernetes GUI

    Get the IP:

    kubectl describe nodes | grep Addresses

    Get the port:

    kubectl get svc kubernetes-dashboard -o json --namespace=kube-system | grep nodePort

    Then go to `http://<IP>:<PORT>`.

    # Reset everything

    minikube stop;
    minikube delete;
    rm -rf ~/.minikube .kube;
    brew uninstall kubectl;
    brew cask uninstall docker virtualbox minikube;

    # TODO

    Will try to convert this to xhyve when possible.
  14. @kevin-smets kevin-smets revised this gist Aug 8, 2017. No changes.
  15. @kevin-smets kevin-smets revised this gist Nov 29, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions kubernetes_on_macOS.md
    Original file line number Diff line number Diff line change
    @@ -96,6 +96,7 @@ Then go to `http://<IP>:<PORT>`.
    # Reset everything

    minikube stop;
    minikube delete;
    rm -rf ~/.minikube .kube;
    brew uninstall kubectl;
    brew cask uninstall docker virtualbox minikube;
  16. @kevin-smets kevin-smets revised this gist Nov 29, 2016. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion kubernetes_on_macOS.md
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,9 @@ If there's output, you're good!
    - minikube
    - virtualbox

    brew update && brew install kubectl && brew cask install docker minikube virtualbox
    ```
    brew update && brew install kubectl && brew cask install docker minikube virtualbox
    ```

    # Verify

  17. @kevin-smets kevin-smets revised this gist Nov 25, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions my-app.yml
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # APP SERVICE
    # APP DEPLOYMENT

    apiVersion: extensions/v1beta1
    kind: Deployment
    @@ -25,7 +25,7 @@ spec:

    ---

    # APP DEPLOYMENT
    # APP SERVICE

    apiVersion: v1
    kind: Service
  18. @kevin-smets kevin-smets renamed this gist Nov 24, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  19. @kevin-smets kevin-smets revised this gist Nov 22, 2016. 2 changed files with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion _kubernetes.md → kubernetes.md
    Original file line number Diff line number Diff line change
    @@ -67,7 +67,7 @@ If you have already built an image, e.g. named 'my-app' locally (check by using

    Check the two yaml files, and run the following:

    kubectl create -f app.yml
    kubectl create -f my-app.yml

    You should now see your pod and your service:

    File renamed without changes.
  20. @kevin-smets kevin-smets revised this gist Nov 22, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion _kubernetes.md
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ If there's output, you're good!
    - minikube
    - virtualbox

    brew install kubectl; brew cask install docker minikube virtualbox
    brew update && brew install kubectl && brew cask install docker minikube virtualbox

    # Verify

  21. @kevin-smets kevin-smets revised this gist Nov 22, 2016. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions app.yml
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # MY APP DEPLOYMENT
    # APP SERVICE

    apiVersion: extensions/v1beta1
    kind: Deployment
    @@ -17,15 +17,15 @@ spec:
    run: my-app
    spec:
    containers:
    - image: localhost:5000/my-app
    - image: localhost:5000/my-app:0.0.1
    name: my-app
    ports:
    - containerPort: 80
    protocol: TCP

    ---

    # MY APP SERVICE
    # APP DEPLOYMENT

    apiVersion: v1
    kind: Service
    @@ -39,5 +39,5 @@ spec:
    protocol: TCP
    targetPort: 80
    selector:
    run: my-app
    run: app-frontend
    type: NodePort
  22. @kevin-smets kevin-smets revised this gist Nov 17, 2016. 1 changed file with 10 additions and 3 deletions.
    13 changes: 10 additions & 3 deletions _kubernetes.md
    Original file line number Diff line number Diff line change
    @@ -6,9 +6,12 @@ Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check th

    If there's output, you're good!

    # Install all the things
    # Prerequisites

    Everything works on Docker for Mac now, so run the following:
    - kubectl
    - docker (for Mac)
    - minikube
    - virtualbox

    brew install kubectl; brew cask install docker minikube virtualbox

    @@ -93,4 +96,8 @@ Then go to `http://<IP>:<PORT>`.
    minikube stop;
    rm -rf ~/.minikube .kube;
    brew uninstall kubectl;
    brew cask uninstall docker virtualbox minikube;
    brew cask uninstall docker virtualbox minikube;

    # TODO

    Will try to convert this to xhyve when possible.
  23. @kevin-smets kevin-smets revised this gist Nov 17, 2016. No changes.
  24. @kevin-smets kevin-smets revised this gist Nov 17, 2016. 4 changed files with 52 additions and 35 deletions.
    13 changes: 9 additions & 4 deletions _kubernetes.md
    Original file line number Diff line number Diff line change
    @@ -64,12 +64,17 @@ If you have already built an image, e.g. named 'my-app' locally (check by using

    Check the two yaml files, and run the following:

    kubectl create -f app-deployment.yml
    kubectl create -f app-service.yml
    kubectl create -f app.yml

    You should now see your pods:
    You should now see your pod and your service:

    kubectl get pods
    kubectl get all

    The configuration exposes `my-app` outside of the cluster, you can get the address to access it by running:

    minikube service my-app --url

    This should give an output like `http://192.168.99.100:30304` (the port will most likely differ).

    # Kubernetes GUI

    17 changes: 0 additions & 17 deletions app-deployment.yml
    Original file line number Diff line number Diff line change
    @@ -1,17 +0,0 @@
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
    name: app
    spec:
    replicas: 2
    template:
    metadata:
    labels:
    name: my-app-deployment
    spec:
    containers:
    - image: localhost:5000/my-app:1.0
    name: app
    ports:
    - name: app-server
    containerPort: 8080
    14 changes: 0 additions & 14 deletions app-service.yml
    Original file line number Diff line number Diff line change
    @@ -1,14 +0,0 @@
    apiVersion: v1
    kind: Service
    metadata:
    name: app
    labels:
    name: my-app-service
    spec:
    type: LoadBalancer
    ports:
    - port: 8080
    targetPort: 8081
    protocol: TCP
    selector:
    name: my-app
    43 changes: 43 additions & 0 deletions app.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    # MY APP DEPLOYMENT

    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
    labels:
    run: my-app
    name: my-app
    spec:
    replicas: 1
    selector:
    matchLabels:
    run: my-app
    template:
    metadata:
    labels:
    run: my-app
    spec:
    containers:
    - image: localhost:5000/my-app
    name: my-app
    ports:
    - containerPort: 80
    protocol: TCP

    ---

    # MY APP SERVICE

    apiVersion: v1
    kind: Service
    metadata:
    labels:
    run: my-app
    name: my-app
    spec:
    ports:
    - port: 80
    protocol: TCP
    targetPort: 80
    selector:
    run: my-app
    type: NodePort
  25. @kevin-smets kevin-smets revised this gist Nov 14, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions _kubernetes.md
    Original file line number Diff line number Diff line change
    @@ -81,8 +81,8 @@ Get the port:

    kubectl get svc kubernetes-dashboard -o json --namespace=kube-system | grep nodePort

    Then go to http://<IP>:<PORT>
    Then go to `http://<IP>:<PORT>`.

    # Reset everything

    minikube stop;
  26. @kevin-smets kevin-smets revised this gist Nov 14, 2016. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions _kubernetes.md
    Original file line number Diff line number Diff line change
    @@ -71,6 +71,18 @@ You should now see your pods:

    kubectl get pods

    # Kubernetes GUI

    Get the IP:

    kubectl describe nodes | grep Addresses

    Get the port:

    kubectl get svc kubernetes-dashboard -o json --namespace=kube-system | grep nodePort

    Then go to http://<IP>:<PORT>

    # Reset everything

    minikube stop;
  27. @kevin-smets kevin-smets revised this gist Nov 14, 2016. No changes.
  28. @kevin-smets kevin-smets revised this gist Nov 14, 2016. 2 changed files with 31 additions and 0 deletions.
    17 changes: 17 additions & 0 deletions app-deployment.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
    name: app
    spec:
    replicas: 2
    template:
    metadata:
    labels:
    name: my-app-deployment
    spec:
    containers:
    - image: localhost:5000/my-app:1.0
    name: app
    ports:
    - name: app-server
    containerPort: 8080
    14 changes: 14 additions & 0 deletions app-service.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    apiVersion: v1
    kind: Service
    metadata:
    name: app
    labels:
    name: my-app-service
    spec:
    type: LoadBalancer
    ports:
    - port: 8080
    targetPort: 8081
    protocol: TCP
    selector:
    name: my-app
  29. @kevin-smets kevin-smets renamed this gist Nov 14, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  30. @kevin-smets kevin-smets revised this gist Nov 14, 2016. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions kubernetes.md
    Original file line number Diff line number Diff line change
    @@ -52,6 +52,25 @@ Running `docker ps` should now output something like:
    332c645bb167 gcr.io/google-containers/kube-addon-manager:v5.1 "/opt/kube-addons.sh" 35 minutes ago Up 35 minutes k8s_kube-addon-manager.92e38b3b_kube-addon-manager-minikube_kube-system_46ae05e07c52d84167b077b142aa4a39_253f9280
    8ea2cd68e0a8 gcr.io/google_containers/pause-amd64:3.0 "/pause" 35 minutes ago Up 35 minutes k8s_POD.d8dbe16c_kube-addon-manager-minikube_kube-system_46ae05e07c52d84167b077b142aa4a39_da8bd6f9

    # Deploy and run an image on your local k8s setup

    First setup a local registry, so Kubernetes can pull the image(s) from there:

    docker run -d -p 5000:5000 --restart=always --name registry registry:2

    If you have already built an image, e.g. named 'my-app' locally (check by using `docker images`), you can publish it to your local repo:

    docker tag my-app localhost:5000/my-app

    Check the two yaml files, and run the following:

    kubectl create -f app-deployment.yml
    kubectl create -f app-service.yml

    You should now see your pods:

    kubectl get pods

    # Reset everything

    minikube stop;