1. Requirements

1) Linux

Not running Linux? Consider running Minikube, or on a cloud provider like Google Compute Engine.

It recommends Ubuntu16.04.

2) Go

You need go in your path (see here for supported versions), please make sure it is installed and in your $PATH.

It recommends Go1.9.2+.

$ wget https://golang.org/dl/go1.9.2.linux-amd64.tar.gz

$ tar -C /usr/local -xzf go1.9.2.linux-amd64.tar.gz

PS: It's better to set environments by adding the following sections into /etc/profile like this:

export PATH=$PATH:/usr/local/go/bin   #GoRoot
export PATH=$PATH:/root/go/bin          #GoPath

3) Docker

At least Docker 1.10+. Ensure the Docker daemon is running and can be contacted (try docker ps).

Some of the Kubernetes components need to run as root, which normally works fine with docker.

$ apt-get install docker.io

$ docker env

4) etcd

You need an etcd in your path, please make sure it is installed and in your $PATH.

It recommends etcd3.2.6+.

$ wget https://github.com/coreos/etcd/releases/download/v3.2.6/etcd-v3.2.6-linux-amd64.tar.gz

$ tar -C /usr/local -xzf etcd-v3.2.6-linux-amd64.tar.gz

5) OpenSSL

You need OpenSSL installed. If you do not have the openssl command available, the script will print an appropriate error.

$ apt-get install openssl

6) CFSSL

The CFSSL binaries (cfssl, cfssljson) must be installed and available on your $PATH.

The easiest way to get it is something similar to the following:

$ apt-get  install  build-essential

$ go get -u github.com/cloudflare/cfssl/cmd/...

PS: This command will download and build cfssl packages into $GOPATH/bin

2. Networking

Kubernetes is using CNI as the networking plugin, like flannel,dhcp,loopback and so forth.

1) Build CNI

$ go get github.com/containernetworking/plugins/...

PS: This command will download and build CNI packages into $GOPATH/bin

2) Add Conf

$ mkdir -p /etc/cni/net.d

$ cat >/etc/cni/net.d/10-mynet.conf <<EOF
{
        "cniVersion": "0.2.0",
        "name": "mynet",
        "type": "bridge",
        "bridge": "cbr0",
        "isGateway": true,
        "ipMasq": false,
        "ipam": {
                "type": "host-local",
                "subnet": "10.1.0.0/24",
                "routes": [
                        { "dst": "0.0.0.0/0" }
                ]
        }
}
EOF
$ cat >/etc/cni/net.d/99-loopback.conf <<EOF
{
        "cniVersion": "0.2.0",
        "type": "loopback"
}
EOF

3. Kubernetes

1) Download

$ git clone https://github.com/kubernetes/kubernetes.git

2) Build

$ cd kubernetes

$ make

3) Set Env

set environments by adding the following sections into /etc/profile like this:

export KUBECONFIG=/var/run/kubernetes/admin.kubeconfig 
export KUBERNETES_PROVIDER=local
export LOG_LEVEL=5
export ALLOW_SECURITY_CONTEXT=true
export ALLOW_PRIVILEGED=true

4) Run

$ cd kubernetes

$ hack/local-up-cluster.sh           # Build and Run

$ hack/local-up-cluster.sh -O      # Already build and Run

5) Test

$ cluster/kubectl.sh get pods
$ cluster/kubectl.sh run my-nginx --image=nginx --replicas=2 --port=80

## begin wait for provision to complete, you can monitor the docker pull by opening a new terminal
$ docker images
## you should see it pulling the nginx image, once the above command returns it
$ docker ps
## you should see your container running!
exit
## end wait

## introspect Kubernetes!
$ cluster/kubectl.sh get pods

PS: The following docker images will be automatically download.

They can be shown by command "docker images".

Actually these containers will be run to provider the Kubernetes DNS Cluster Service.

gcr.io/google_containers/k8s-dns-sidecar-amd64

gcr.io/google_containers/k8s-dns-kube-dns-amd64

gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64

gcr.io/google_containers/pause-amd64

## create a service for nginx, which serves on port 80
$ cluster/kubectl.sh expose deployment my-nginx --port=80 --name=my-nginx 

4. Trouble Shooting

1) swap

    • Error

  Running with swap on is not supported, please disable swap!

    • Solution

* Identify configured swap devices and files with cat /proc/swaps.

* Turn off all swap devices and files with swapoff -a.

* Remove any matching reference found in /etc/fstab.

* Optional: Destroy any swap devices or files found in step 1 to prevent their reuse.

* Due to your concerns about leaking sensitive information, you may wish to consider performing some sort of secure wipe.

  2) Improvement

  $ vi s.sh

   ~/go/src/kubernetes/hack/local-up-cluster.sh -O

  $ source s.sh      # simply to run kubernetes server

$ cp kubernetes/_output/bin/kubelet /usr/local/bin/

$ kubelet           # simply to replace cluster/kubectl.sh into kubelet

$ alias k=kubectl

  3) Improvement

# export SERVICE_ACCOUNT_LOOKUP=false

# export HOSTNAME_OVERRIDE=SZX1000341409

# export NET_PLUGIN=kubenet      #just for gce

# export KUBELET_HOST=0.0.0.0

$ kubectl exec POD_NAME -it /bin/bash

$ kubetl get all --all-namespaces=true

$ kubectl logs

$ kubectl get node -o yaml

$ kubectl cluster-info dump

$ update-rc.d ServiceName remove

Kubernetes Running Locally的更多相关文章

  1. 问题解决:psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

    错误提示: psql: could not connect to server: No such file or directory Is the server running locally and ...

  2. 问题解决:psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

    错误提示: psql: could not connect to server: No such file or directory Is the server running locally and ...

  3. 关于Kubernetes(简称K8S)的开启及基本使用,基于Docker Desktop & WSL2

    背景介绍 Kubernetes(简称k8s)已成为目前业界容器编排的事实标准,其搭配Docker可建立非常高效便捷的高可扩展.高可用应用服务架构. Kubernetes的名字来自希腊语,意思是&quo ...

  4. Announcing the public preview of Azure Dev Spaces

    Today, we are excited to announce the public preview of Azure Dev Spaces, a cloud-native development ...

  5. docker官方文档学习-1-Docker for mac安装配置

    https://docs.docker.com/docker-for-mac/ Get started with Docker for Mac 首先像在本博客docker-1-环境安装及例子实践处将环 ...

  6. Distributed Phoenix Chat with PubSub PG2 adapter

    转自:https://www.poeticoding.com/distributed-phoenix-chat-with-pubsub-pg2-adapter/ In this article we’ ...

  7. spark源码分析以及优化

    第一章.spark源码分析之RDD四种依赖关系 一.RDD四种依赖关系 RDD四种依赖关系,分别是 ShuffleDependency.PrunDependency.RangeDependency和O ...

  8. [转]gitlab ci/cd 发布

    转自 https://meigit.readthedocs.io/en/latest/configure_gitlab_i18n_and_create_gitlab_ci_with_gitlab_ru ...

  9. 在PC上测试移动端网站和模拟手机浏览器的5大方

    查了很多资料,尝试了大部分方法,下面将这一天的努力总结下分享给大家,也让大家免去看那么多文章,以下介绍的方法,都是本人亲自测试成功的方法,测试环境winxp. 一.Chrome*浏览器 chrome模 ...

随机推荐

  1. C++/Java中继承关系引发的调用关系详解

    C++: 这里引用到了 http://blog.csdn.net/haoel/article/details/1948051/ 中的内容,还请提前阅读陈大神的这篇博客后在阅读本篇. 覆盖,实现多态的基 ...

  2. 怎么用谷歌浏览器查看请求或响应HTTP头?

    要使用谷歌浏览器查看请求或响应HTTP标头,可以采取以下步骤: 在Chrome浏览器,访问一个网址,点击右键,选择检查,打开开发人员工具(或直接按F12). 选择 Network 选项卡. 重新加载页 ...

  3. unigui的UnimDatePicker控件使用经验

    最近使用unigui的UnimDatePicker控件遇到只能选择当年之前的年份和日期及日期选择界面不能显示中文的问题,经以下设置就能正常使用.1.UnimDatePicker月份显示中文  unim ...

  4. [JQuery]ScrollMe滚动特效插件

    最近考完试,一切顺利,昨晚闲着无聊把最近要用的一个插件翻译了一下:ScrollMe. (╯‵□′)╯︵┻━┻地址请戳: /* ScrollMe -李明夕翻译(╯‵□′)╯︵┻━┻ */ ScrollM ...

  5. Eclipase + CDT

    1. 参考 https://blog.csdn.net/imlsz/article/details/50441830 https://blog.csdn.net/happylife1527/artic ...

  6. SP2666 QTREE4 - Query on a tree IV(LCT)

    题意翻译 你被给定一棵n个点的带边权的树(边权可以为负),点从1到n编号.每个点可能有两种颜色:黑或白.我们定义dist(a,b)为点a至点b路径上的权值之和. 一开始所有的点都是白色的. 要求作以下 ...

  7. redis 3.0 集群__安装

    参考文档 http://redis.io/topics/cluster-tutorial http://redis.io/topics/cluster-spec http://redis.readth ...

  8. now() 的用法

    在平时对于数据库操作中,有时候会使用到时间,比如-数据的创建时间/更新时间之类问题,可能是需要查询出时间的结果,也存在大量的需要搜索某个时间点或时间段的操作: MySQL中取本地时间 now() 取本 ...

  9. php中模拟post,get请求和接受请求详细讲解

    在php中我们经常用到curl拓展来进行模拟post.get请求,下面就来具体说说怎么模拟: 一.首先模拟post请求: function http_post_data($url, $query_da ...

  10. PHP开发微信公众号(一)二维码的获取

    要开发微信公众号,首先进行需要注册一个,然后认证.这就不用多说了. 当然如果没有,也可以去申请一个测试号来使用,地址:https://mp.weixin.qq.com/debug/cgi-bin/sa ...