Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Docker Kubernetes get started quickly


May 22, 2021 Docker From entry to practice


Table of contents


Today, Kubernetes supports installation in a variety of environments, including on-premises hosts (Fedora), cloud services (Google GAE, AWS, and so on). However, the quickest way to experience Kubernetes is clearly to start the process locally through Docker.

The following illustration shows the topology of a set of Kubernetes deployed quickly in a single node using Docker.


Docker Kubernetes get started quickly

Kubernetes relies on the Etcd service to maintain the state of all primary nodes.

Start the Etcd service

  1. docker run --net=host -d gcr.io/google_containers/etcd:2.0.9 /usr/local/bin/etcd --addr=127.0.0.1:4001 --bind-addr=0.0.0.0:4001 --data-dir=/var/etcd/data


Start the primary node

Start the kubelet.

  1. docker run --net=host -d -v /var/run/docker.sock:/var/run/docker.sock gcr.io/google_containers/hyperkube:v0.17.0 /hyperkube kubelet --api_servers=http://localhost:8080 --v=2 --address=0.0.0.0 --enable_server --hostname_override=127.0.0.1 --config=/etc/kubernetes/manifests

Start the service agent

  1. docker run -d --net=host --privileged gcr.io/google_containers/hyperkube:v0.17.0 /hyperkube proxy --master=http://127.0.0.1:8080 --v=2

The test status

Access the 8080 port locally and get the following results:

  1. $ curl 127.0.0.1:8080
  2. {
  3. "paths": [
  4. "/api",
  5. "/api/v1beta1",
  6. "/api/v1beta2",
  7. "/api/v1beta3",
  8. "/healthz",
  9. "/healthz/ping",
  10. "/logs/",
  11. "/metrics",
  12. "/static/",
  13. "/swagger-ui/",
  14. "/swaggerapi/",
  15. "/validate",
  16. "/version"
  17. ]
  18. }

View the service

After all services are started, look at the Docker containers that are actually running locally, and there are several.

  1. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  2. ee054db2516c gcr.io/google_containers/hyperkube:v0.17.0 "/hyperkube schedule 2 days ago Up 1 days k8s_scheduler.509f29c9_k8s-master-127.0.0.1_default_9941e5170b4365bd4aa91f122ba0c061_e97037f5
  3. 3b0f28de07a2 gcr.io/google_containers/hyperkube:v0.17.0 "/hyperkube apiserve 2 days ago Up 1 days k8s_apiserver.245e44fa_k8s-master-127.0.0.1_default_9941e5170b4365bd4aa91f122ba0c061_6ab5c23d
  4. 2eaa44ecdd8e gcr.io/google_containers/hyperkube:v0.17.0 "/hyperkube controll 2 days ago Up 1 days k8s_controller-manager.33f83d43_k8s-master-127.0.0.1_default_9941e5170b4365bd4aa91f122ba0c061_1a60106f
  5. 30aa7163cbef gcr.io/google_containers/hyperkube:v0.17.0 "/hyperkube proxy -- 2 days ago Up 1 days jolly_davinci
  6. a2f282976d91 gcr.io/google_containers/pause:0.8.0 "/pause" 2 days ago Up 2 days k8s_POD.e4cc795_k8s-master-127.0.0.1_default_9941e5170b4365bd4aa91f122ba0c061_e8085b1f
  7. c060c52acc36 gcr.io/google_containers/hyperkube:v0.17.0 "/hyperkube kubelet 2 days ago Up 1 days serene_nobel
  8. cc3cd263c581 gcr.io/google_containers/etcd:2.0.9 "/usr/local/bin/etcd 2 days ago Up 1 days happy_turing

These services fall into three categories: primary node services, work node services, and other services.

The primary node service

  • Apiserver is the external interface of the entire system, providing reSTful for clients and other components to call;
  • Scheduler is responsible for scheduling resources and assigning a pod to a node;
  • Controller-manager is responsible for managing the controller, including endpoint-controller (refresh service and pod association information) and replication-controller (maintaining the values that a pod is copied to configure).

The work node service

  • Kubelet is the agent of the work node to perform the operation, is responsible for the specific container lifecycle management, according to the information obtained from the database to manage the container, and report the pod operation status, etc.
  • proxy provides access to services on the pod.

Other services

  • Etcd is a storage database for all states;
  • gcr.io/google_containers/pause:0.8.0 is a test image that automatically pulls down after Kubernetes starts.