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.
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:
Install etcd:
Install golang (should be version 1.8+):
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.
Add Kubernetes sources to GOPATH:
Step 4: Compile and run Kubernetes
It's not difficult here, because it happens to have a good one called local-up-cluster.sh.
The output shows:
Step 5: Test Kubernetes
The virtual machine opens a new shell , cd to the Kubernetes source directory GOPATH, and then you can test:
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:
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:
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