Take you to play with Kubernetes

Kubernetes is a well-known container management system. It is a large open source project with many contributors. As a non-picky container management framework, it can be used everywhere. In the past two days, I have been exposed to K8s and will take you to play with K8s. This tutorial can roughly let you know how to run and change the source code, and test the local Kubernetes platform cluster from scratch.

Kubernetes is a large open source project with many contributors. In theory, as a non-picky container management framework, it can be ubiquitous. Unfortunately, bootstrapping a kubernetes server is not easy, either by actually writing or contributing test code. Some of the files in it are a bit messy to me, either hanging or outdated. There are very few examples of source file changes and compilation and operation. If you run kubernets cluster locally, you must start from scratch and move forward.
Let's share some exploration experience, try to explain in detail from the beginning, let's chat together.

Step 1: Create a virtual machine and access

Since you are starting from scratch, you have to put on a show. Start by creating a new, clean VM to run.

Take you to play with Kubernetes Take you to play with Kubernetes

So far, the new Google Cloud Platform VM instance has been created, which is a clean and pollution-free new environment.

Step 2: Prepare Virtual Machines for Kubernetes

This step is to install:

GCC,Make,socat和git;
Docker;
Others depend on your own needs, if you don’t have any needs, don’t worry about it.

ssh into the new VM above, install GCC, Make, socat and git:

Take you to play with Kubernetes Take you to play with Kubernetes


Install etcd:

Take you to play with Kubernetes Take you to play with Kubernetes


Install golang (should be version 1.8+):

Take you to play with Kubernetes Take you to play with Kubernetes

Step 3: Get the Kubernetes source code

At this step, the Git Kubernetes source code is cloned and added to GOPATH. Note that –depth 1 is used here, that is, only the latest version is required.

Take you to play with Kubernetes Take you to play with Kubernetes

Add Kubernetes sources to GOPATH:

Take you to play with Kubernetes Take you to play with Kubernetes

Step 4: Compile and run Kubernetes

It's not difficult here, because it happens to have a good one called local-up-cluster.sh.

Take you to play with Kubernetes Take you to play with Kubernetes

The output shows:

Take you to play with Kubernetes Take you to play with Kubernetes

Step 5: Test Kubernetes

The virtual machine opens a new shell , cd to the Kubernetes source directory GOPATH, and then you can test:

Take you to play with Kubernetes Take you to play with Kubernetes

Step 6: Change the source code

Add a log line to the kubernetes-apiserver to change the entry point, and make sure you can see this in the log:

Take you to play with Kubernetes Take you to play with Kubernetes

Step 7: Test changes to the Kubernetes source code

Stop the local cluster, restart root@instance-3:/gopath/src/k8s.io/kubernetes# hack/local-up-cluster.sh

Check the tail api server log line for any changes:

Take you to play with Kubernetes Take you to play with Kubernetes

This is the documentation for creating a local Kubernetes cluster from scratch, no hassle, but it also covers some of the more important points: performed a few simple steps, got a Kubernetes cluster, compiled and changed the API server, and then viewed the changes.

Article from: WeChat public account: DevOps Research Institute

Guess you like

Origin blog.csdn.net/yaxuan88521/article/details/131817928