Minikube Code Analysis and go language-3

Source: Internet
Author: User
Tags cockroachdb etcd k8s
This is a creation in Article, where the information may have evolved or changed.

[TOC]

Minikube Code Analysis

Reference Blog: minikube Source Analysis

Download

Minikube source code can be downloaded from github:

git clone git@github.com:kubernetes/minikube.git

Compile

Environment:Ubuntu 16.04

# code download to any directory, here is/opt/kube/minikube> Export gopath=~/gol/# Set GOPATH environment variable, here is ~/gol> mkdir-p ~/gol/src/k8s.io/# K8 S.io This directory name is important, Minikube's package is based on this > CD ~/gol/src/k8s.io/> ln-s/opt/kube/minikube/minikube # link to the source directory > Make # Compile cgo_enabled=1 go build-tags static_build-ldflags= "-X k8s.io/minikube/vendor/k8s.io/kubernetes/pkg/via Makefile Version.gitcommit=d6f433224538d4f9ca2f7ae19b252e6fcb66a3ae-x k8s.io/minikube/vendor/k8s.io/kubernetes/pkg/ Version.gitversion=v1.6.4-x K8s.io/minikube/vendor/k8s.io/kubernetes/pkg/version.gittreestate=clean-x k8s.io/ Minikube/vendor/k8s.io/kubernetes/pkg/version.builddate=2017-07-06t18:19:23z-x k8s.io/minikube/pkg/ Version.version=v0.20.0-x K8s.io/minikube/pkg/version.isoversion=v0.20.0-x k8s.io/minikube/pkg/version.isopath= Minikube/iso-s-w-extldflags '-static ' "-O./out/localkube./cmd/localkubegobin=/home/stack/gol//bin Go get github.com /jteeuwen/go-bindata/.../home/stack/gol//bin/go-bindata-nomemcopy-o Pkg/minikube/assets/assEts.go-pkg assets./out/localkube deploy/addons/... Cgo_enabled=1 goarch=amd64 goos=linux Go build--installsuffix cgo-ldflags= "-X k8s.io/minikube/pkg/version.version= V0.20.0-x K8s.io/minikube/pkg/version.isoversion=v0.20.0-x K8s.io/minikube/pkg/version.isopath=minikube/iso-x K8s.io/minikube/vendor/k8s.io/kubernetes/pkg/version.gitcommit=d6f433224538d4f9ca2f7ae19b252e6fcb66a3ae-x K8s.io/minikube/vendor/k8s.io/kubernetes/pkg/version.gitversion=v1.6.4-x k8s.io/minikube/vendor/k8s.io/ Kubernetes/pkg/version.gittreestate=clean-x k8s.io/minikube/vendor/k8s.io/kubernetes/pkg/version.builddate= 2017-07-06t18:19:23z "-a-o out/minikube-linux-amd64 K8S.IO/MINIKUBE/CMD/MINIKUBECP./out/minikube-linux-amd64./out /minikube

Output Information Highlights:

    • minikube 0.20.0Default usagekubernetes v1.6.4

    • https://github.com/jteeuwen/go-bindata/downloaded from ago-bindata

    • The compiled files are in the out directory and are not small in size:

> ls -lh minikube/outtotal 267M-rwxrwxr-x  1 stack stack 116M 7月   6 18:33 localkube*-rwxrwxr-x  1 stack stack  76M 7月   6 18:35 minikube*-rwxrwxr-x  1 stack stack  76M 7月   6 18:35 minikube-linux-amd64*

File

    • cmdThe directory is localkube the minikube entrance to the program

    • cmd/minikube/cmdThe following is minikube the implementation of all subcommands, one for each sub-command

    • Use the Cobra library to support git parametric processing of shapes

Go projects at a glance

Project Description
Kubernetes 10 minutes to take you to understand kubernetes core concepts
Hugo Use Hugo to build a personal blog site
Rkt Three years later, we transferred from Docker to RKT.
Etcd What is ETCD? What's the difference between it and zookeeper?
Moby What do you think about Docker renaming Moby?
OpenShift OpenShift 3, Red Hat gives the power of the container to the developer
Delve Golang/go Debugging Tools Delve
Gopherjs Yi go to JavaScript to write front-end code in go language
Cockroachdb cockroachdb--like a cockroach. Indestructible database
Bleve Full-text Search and indexing for Go
Projectatomic Selection and use of container OS
Giantswarm Container Eco-Circle Project List
Nanopack The ideal platform for developers
Rclone Rclone: Easy to use network disk/VPS data synchronization, backup tools

Update k8s

Reference Documentation:minikube/docs/contributors/updating_kubernetes.md

> ~/gol/src/k8s.io/minikube  # 先进入到 minikube 代码目录> go get github.com/tools/godep  # 需要godep,默认下载到$GOPATH/bin> ./hack/godeps/godep-restore.sh  # 下载Kubernetes

Go Language Introduction

3-Data type

The type of Go is divided into four categories:

    1. Base type: number, String, and Boolean value

    2. Aggregation types: arrays and struct bodies

    3. Reference types: Pointers, lists, dictionaries, functions, and pipelines

    4. Interface type: interface

  • GoThe math, logical, and comparison operators are the C same, and the precedence is the same

  • To make explicit conversions between different types,mismatched types int32 and int16

  • Conversion operations are supported for any typeT(x)

  • runeis a Unicode single character type that is supported

  • floatType through math package support IEEE 754 specification (as usual weird)

    • The original book gave a perverted example to show the generation of three-dimensional surface, with can take a look go get gopl.io/ch3/surface/ ... (also included in the book is a three-dimensional space and isometric projection, so it is really suitable for use in the Basic Language tutorial TLTD; ...) )

  • Supports complex numbers (routines are generated with code Mandelbrot fractals ... This is the book of Graphic Science.

  • bool0, 1There is no implicit conversion between type and number type

  • A string is a collection of bytes that can be included 0 , the default UTF-8 encoding

  • The string supports slicing, as s[:5], s[7:], s[:] with Python similar

  • The escape character C is the same as the explanation.\r \n \t \\ ...

  • ' Anti-quotation marks indicate literal characters, are not escaped, can be used for regular, template, etc.

  • bytes, strings, strconv, unicodeFour packages that are particularly important for string manipulation

  • Constants Support Boolean, String, and numeric

  • iotais the constant generator, initially 0, and each of the remaining increments

type Weekday intconst (    Sunday Weekday = iota   // 0    Monday                  // 1    Tuesday                 // 2 ...    Wednesday    Thursday    Friday    Saturday)
    • Constants can have no type, and the current type is applied when the operation is

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.