在搭建开发环境之前, 请Try KubernetesGet Started and CONCEPTS

可以自己使用minikube 来搭建个环境, 自己玩一玩。

K8s需要一些依赖。 参看官方文档

https://github.com/kubernetes/community/blob/master/contributors/devel/running-locally.md

1. 需要安装 linux

2. 安装docker

wget -O- https://get.docker.com/ |bash
sudo usermod -aG docker $USER

3. 安装etcd

hack/install-etcd.sh  # Installs in ./third_party/etcd
echo "export PATH=\"\$PATH:$(pwd)/third_party/etcd\"" >> ~/.profile  # Add to PATH

4. 安装go

sudo add-apt-repository ppa:gophers/archive
sudo apt update
sudo apt-get install golang-1.9-go cat >> ~/.profile <<<'
GOROOT=`go env |grep "GOROOT" |cut -d "=" -f2`
GOROOT=${GOROOT#\"}
GOROOT=${GOROOT%\"} GOPATH=`go env |grep GOPATH |cut -d "=" -f 2`
GOPATH=${GOPATH%\"}
GOPATH=${GOPATH#\"}' echo "export PATH=\$PATH:/usr/lib/go-1.9/bin" >> ~/.profile
source ~/.profile

5. 安装 openssl

6. 安装 CFSSL

go get -u github.com/cloudflare/cfssl/cmd/...
echo "export PATH=\$PATH:\$GOPATH/bin" >> ~/.profile
source ~/.profile

7. 下载源码

git clone --depth=1 https://github.com/kubernetes/kubernetes.git

8. 编译安装k8s

cd kubernetes

hack/local-up-cluster.sh

9. 可以开发了。

请参看 devel  重点 coding-conventions

go调试, 请参考 golang debug, 推荐使用Delve

=============================

参考文档:

https://kubernetes.io/

开发者主要看看: Community 和 Documentation

附录:

编译过程:

$ hack/local-up-cluster.sh
WARNING : The kubelet is configured to not fail if swap is enabled; production deployments should disable swap.
WARNING : This script MAY be run as root for docker socket / iptables functionality; if failures occur, retry as root.
make: Entering directory '/home/ubuntu/kubernetes'
make[]: Entering directory '/home/ubuntu/kubernetes'
+++ [ ::] Building the toolchain targets:
k8s.io/kubernetes/hack/cmd/teststale
k8s.io/kubernetes/vendor/github.com/jteeuwen/go-bindata/go-bindata
+++ [ ::] Generating bindata:
test/e2e/generated/gobindata_util.go
~/kubernetes ~/kubernetes/test/e2e/generated
~/kubernetes/test/e2e/generated
+++ [ ::] Building go targets for linux/amd64:
./vendor/k8s.io/code-generator/cmd/deepcopy-gen
+++ [ ::] Building the toolchain targets:
k8s.io/kubernetes/hack/cmd/teststale
k8s.io/kubernetes/vendor/github.com/jteeuwen/go-bindata/go-bindata
+++ [ ::] Generating bindata:
test/e2e/generated/gobindata_util.go
~/kubernetes ~/kubernetes/test/e2e/generated
~/kubernetes/test/e2e/generated
+++ [ ::] Building go targets for linux/amd64:
./vendor/k8s.io/code-generator/cmd/defaulter-gen
+++ [ ::] Building the toolchain targets:
k8s.io/kubernetes/hack/cmd/teststale
k8s.io/kubernetes/vendor/github.com/jteeuwen/go-bindata/go-bindata
+++ [ ::] Generating bindata:
test/e2e/generated/gobindata_util.go
~/kubernetes ~/kubernetes/test/e2e/generated
~/kubernetes/test/e2e/generated
+++ [ ::] Building go targets for linux/amd64:
./vendor/k8s.io/code-generator/cmd/conversion-gen
+++ [ ::] Building the toolchain targets:
k8s.io/kubernetes/hack/cmd/teststale
k8s.io/kubernetes/vendor/github.com/jteeuwen/go-bindata/go-bindata
+++ [ ::] Generating bindata:
test/e2e/generated/gobindata_util.go
~/kubernetes ~/kubernetes/test/e2e/generated
~/kubernetes/test/e2e/generated
+++ [ ::] Building go targets for linux/amd64:
./vendor/k8s.io/code-generator/cmd/openapi-gen
make[]: Leaving directory '/home/ubuntu/kubernetes'
+++ [ ::] Building the toolchain targets:
k8s.io/kubernetes/hack/cmd/teststale
k8s.io/kubernetes/vendor/github.com/jteeuwen/go-bindata/go-bindata
+++ [ ::] Generating bindata:
test/e2e/generated/gobindata_util.go
~/kubernetes ~/kubernetes/test/e2e/generated
~/kubernetes/test/e2e/generated
+++ [ ::] Building go targets for linux/amd64:
cmd/kubectl
cmd/hyperkube
+++ [ ::] +++ Warning: stdlib pkg with cgo flag not found.
+++ [ ::] +++ Warning: stdlib pkg cannot be rebuilt since /usr/lib/go-1.9/pkg is not writable by ubuntu
+++ [ ::] +++ Warning: Make /usr/lib/go-1.9/pkg writable for ubuntu for a one-time stdlib install, Or
+++ [ ::] +++ Warning: Rebuild stdlib using the command 'CGO_ENABLED=0 go install -a -installsuffix cgo std'
+++ [ ::] +++ Falling back to go build, which is slower
**
make: Leaving directory '/home/ubuntu/kubernetes'
WARNING: No swap limit support
Kubelet cgroup driver defaulted to use: cgroupfs
API SERVER insecure port is free, proceeding...
API SERVER secure port is free, proceeding...
Detected host and ready to start services. Doing some housekeeping first...
Using GO_OUT /home/ubuntu/kubernetes/_output/local/bin/linux/amd64
Starting services now!
Starting etcd
etcd --advertise-client-urls http://127.0.0.1:2379 --data-dir /tmp/tmp.lG7Vdi3iOj --listen-client-urls http://127.0.0.1:2379 --debug > "/dev/null" 2>/dev/null
Waiting for etcd to come up.
+++ [ ::] On try , etcd: : http://127.0.0.1:2379
{"action":"set","node":{"key":"/_test","value":"","modifiedIndex":,"createdIndex":}}
Generating a bit RSA private key
...............+++
.....................................................................................................................+++
writing new private key to '/var/run/kubernetes/server-ca.key'
-----
Generating a bit RSA private key
..................+++
................................................+++
writing new private key to '/var/run/kubernetes/client-ca.key'
-----
Generating a bit RSA private key
....................................................................+++
.....................................+++
writing new private key to '/var/run/kubernetes/request-header-ca.key'
-----
// :: [INFO] generate received request
// :: [INFO] received CSR
// :: [INFO] generating key: rsa-
// :: [INFO] encoded CSR
// :: [INFO] signed certificate with serial number
// :: [INFO] generate received request
// :: [INFO] received CSR
// :: [INFO] generating key: rsa-
// :: [INFO] encoded CSR
// :: [INFO] signed certificate with serial number
// :: [INFO] generate received request
// :: [INFO] received CSR
// :: [INFO] generating key: rsa-
// :: [INFO] encoded CSR
// :: [INFO] signed certificate with serial number
// :: [INFO] generate received request
// :: [INFO] received CSR
// :: [INFO] generating key: rsa-
// :: [INFO] encoded CSR
// :: [INFO] signed certificate with serial number
// :: [INFO] generate received request
// :: [INFO] received CSR
// :: [INFO] generating key: rsa-
// :: [INFO] encoded CSR
// :: [INFO] signed certificate with serial number
// :: [INFO] generate received request
// :: [INFO] received CSR
// :: [INFO] generating key: rsa-
// :: [INFO] encoded CSR
// :: [INFO] signed certificate with serial number
// :: [INFO] generate received request
// :: [INFO] received CSR
// :: [INFO] generating key: rsa-
// :: [INFO] encoded CSR
// :: [INFO] signed certificate with serial number
// :: [INFO] generate received request
// :: [INFO] received CSR
// :: [INFO] generating key: rsa-
// :: [INFO] encoded CSR
// :: [INFO] signed certificate with serial number
// :: [INFO] generate received request
// :: [INFO] received CSR
// :: [INFO] generating key: rsa-
// :: [INFO] encoded CSR
// :: [INFO] signed certificate with serial number
Waiting for apiserver to come up
+++ [ ::] On try , apiserver: : ok
Cluster "local-up-cluster" set.
use 'kubectl --kubeconfig=/var/run/kubernetes/admin-kube-aggregator.kubeconfig' to use the aggregated API server
service "kube-dns" created
serviceaccount "kube-dns" created
configmap "kube-dns" created
deployment "kube-dns" created
Kube-dns addon successfully deployed.
kubelet ( ) is running.
Create default storage class for
storageclass "standard" created
Local Kubernetes cluster is running. Press Ctrl-C to shut it down. Logs:
/tmp/kube-apiserver.log
/tmp/kube-controller-manager.log
/tmp/kube-proxy.log
/tmp/kube-scheduler.log
/tmp/kubelet.log To start using your cluster, you can open up another terminal/tab and run: export KUBECONFIG=/var/run/kubernetes/admin.kubeconfig
cluster/kubectl.sh Alternatively, you can write to the default kubeconfig: export KUBERNETES_PROVIDER=local cluster/kubectl.sh config set-cluster local --server=https://localhost:6443 --certificate-authority=/var/run/kubernetes/server-ca.crt
cluster/kubectl.sh config set-credentials myself --client-key=/var/run/kubernetes/client-admin.key --client-certificate=/var/run/kubernetes/client-admin.crt
cluster/kubectl.sh config set-context local --cluster=local --user=myself
cluster/kubectl.sh config use-context local
cluster/kubectl.sh

k8s开发环境的更多相关文章

  1. cert-manager管理内网k8s开发环境证书

    目的 内网k8s开发环境配置HTTPS,保持与生产环境的配置的一致性,其必要性有: PWA开发,HTTPS是必要条件 网页引入HTTP资源,如果开发环境是HTTP就不会被开发和测试人员发现,造成生产环 ...

  2. Blazor+Dapr+K8s微服务之开发环境调试

    1         安装Dapr开发调试环境 1.1         Dapr 完整安装模式不支持开发调试 在上一篇随笔<Blazor+Dapr+K8s微服务之服务调用>中,我们通过为每个 ...

  3. docker-swarm建立本地集成开发环境

    在k8s出现之后,docker-swarm使用的人越来越少,但在本地集成开发环境的搭建上,使用它还是比较轻量级的,它比docker-compose最大的好处就是容器之间的共享和服务的治理,你不需要li ...

  4. 我如何通过K8S开发认证(CKAD)考试

    题记:笔者最近经过3个多月的空余时间准备,终于通过了K8S开发认证(CKAD)的考试,在这里简单给大家分享一下经验. 一,先科普下CKAD 众所周知,Kubernetes在容器编排器大战中脱颖而出后, ...

  5. 开发环境下的 Kubernetes 容器网络演进之路

    马蜂窝技术原创文章,更多干货请搜索公众号:mfwtech 使用 Docker+Kubernetes 来简化开发人员的工作流,使应用更加快速地迭代,缩短发布周期,在很多研发团队中已经是常见的做法. 如果 ...

  6. Vagrant - 打造跨平台的一致开发环境

    官网 参考资料 借助 Vagrant ,可以使用 Vagrantfile 文件自动化虚拟机的安装和配置流程,方便快速的打造跨平台的统一开发环境. 1. Vagrant 是啥 Vagrant 用于构建及 ...

  7. 解放开发者!3款工具实现快速K8S开发

    本文转自Rancher Labs 关注我们,即可第一时间获取K8S教程哦 简 介 时至今日,Kubernetes正在变得越来越重要,不仅仅是运维需要Kubernetes,在开发的世界里Kubernet ...

  8. Newbe.Claptrap 框架入门,第一步 —— 开发环境准备

    Newbe.Claptrap 框架依托于一些关键性的基础组件和一些可选的辅助组件.本篇我们来介绍一下如何准备一个开发环境. Newbe.Claptrap 是一个用于轻松应对并发问题的分布式开发框架.如 ...

  9. 通过Dapr实现一个简单的基于.net的微服务电商系统(十四)——开发环境容器调试小技巧

    之前有很多同学提到如何做容器调试,特别是k8s环境下的容器调试,今天就讲讲我是如何调试的.大家都知道在vs自带的创建项目模板里勾选docker即可通过F5启动docker容器调试.但是对于启动在k8s ...

随机推荐

  1. 关于事件循环机制event loop

    setTimeout(()=> { console.log('settimeout') },100) console.log('开始') console.log('结束') new Promis ...

  2. Oracle推进SCN系列:使用oradebug在mount状态下推进SCN

    环境:RHEL 6.5(x86-64) + Oracle 11.2.0.4 声明:推进SCN属于非常规恢复范畴,不建议非专业人员操作,否则后果自负. 需求:我这里演示下推进SCN 10W数量级,实际需 ...

  3. 27.给input边框和背景颜色设置全透明

    给input边框和背景颜色设置全透明,但是里面的字不会消失 1.让背景颜色变透明(二选一) background-color:rgba(0,0,0,0); background:rgba(0,0,0, ...

  4. ajax提交完表单数据依然跳转的解决办法

    1. 既然ajax提交数据,就把表单里面submit按钮换掉,因为触发submit他就会跳转页面 提交的时候他会先触发ajax 再触发submit的提交 2.如果确定了表单没有submit,那么把提交 ...

  5. python number

    一.number类型转换 int(x [,base ]) 将x转换为一个整数 long(x [,base ]) 将x转换为一个长整数 float(x ) 将x转换到一个浮点数 complex(real ...

  6. Javascript-数据类型转换 、 运算符和表达式

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. pandas常用函数

    1. df.head(n): 显示数据前n行,不指定n,df.head则会显示所有的行 2. df.columns.values获取所有列索引的名称 3. df.column_name: 直接获取列c ...

  8. c#之如何计算哈希值字符串

    代码如下: /// <summary> /// 计算哈希值字符串 /// </summary> public static string ComputeHash(byte[] ...

  9. RocketMQ的使用

    1 在resources目录下创建config目录,新建文件rocketmq.properties文件 # 指定namesrv地址 suning.rocketmq.namesrvAddr=localh ...

  10. QT获取窗口句柄

    winId()函数 SendMessage((HWND)(this->dlg->winId()),WM_SEND_MY_MESSAGE,0,0);