How to create a local development environment for Kubernetes?

前端 未结 12 1604
谎友^
谎友^ 2020-12-22 18:59

Kubernetes seems to be all about deploying containers to a cloud of clusters. What it doesn\'t seem to touch is development and staging environments (or such).

Durin

相关标签:
12条回答
  • 2020-12-22 19:11

    Update (2016-07-15)

    With the release of Kubernetes 1.3, Minikube is now the recommended way to run Kubernetes on your local machine for development.


    You can run Kubernetes locally via Docker. Once you have a node running you can launch a pod that has a simple web server and mounts a volume from your host machine. When you hit the web server it will read from the volume and if you've changed the file on your local disk it can serve the latest version.

    0 讨论(0)
  • 2020-12-22 19:12

    I've just started with Skaffold

    It's really useful to apply changes in the code automatically to a local cluster.

    To deploy a local cluster, the best way is Minikube or just Docker for Mac and Windows, both includes a Kubernetes interface.

    0 讨论(0)
  • 2020-12-22 19:13

    As specified before by Robert, minikube is the way to go.

    Here is a quick guide to get started with minikube. The general steps are:

    • Install minikube

    • Create minikube cluster (in a Virtual Machine which can be VirtualBox or Docker for Mac or HyperV in case of Windows)

    • Create Docker image of your application file (by using Dockerfile)

    • Run the image by creating a Deployment

    • Create a service which exposes your application so that you can access it.

    0 讨论(0)
  • 2020-12-22 19:20

    Kubespary is helpful setting up local clusters. Mostly, I used vagrant based cluster on local machine.

    Kubespray configuration You could tweak these variables to have the desired kubernetes version.

    0 讨论(0)
  • 2020-12-22 19:21

    Here is the way I did a local set up for Kubernetes in Windows 10: -

    • Use Docker Desktop

    • Enable Kubernetes in the settings option of Docker Desktop

    • In Docker Desktop by default resource allocated for Memory is 2GB so to use Kubernetes with Docker Desktop increase the memory.

    • Install kubectl as a client to talk to Kubernetes cluster

    • Run command kubectl config get-contexts to get the available cluster

    • Run command kubectl config use-context docker-desktop to use the docker desktop

    • Build a docker image of your application

    • Write a YAML file (descriptive method to create your deployment in Kubernetes) pointing to the image created in above step cluster

    • Expose a service of type node port for each of your deployment to make it available to the outside world

    0 讨论(0)
  • 2020-12-22 19:22

    See https://github.com/kubernetes/kubernetes/issues/12278 for how to mount a volume from the host machine, the equivalent of:

    docker run -v hostPath:ContainerPath
    
    0 讨论(0)
提交回复
热议问题