使用kubeadm命令,执行:kubeadm reset

重新执行初始化:kubeadm init --kubernetes-version=v1.14.1 --pod-network-cidr=10.245.0.0/16

mkdir -p $HOME/.kube

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

sudo chown $(id -u):$(id -g) $HOME/.kube/config

执行完上述的几个命令,理论上K8S已经启动了,但是由于Flannel没有安装,导致node节点依然是notReady状态。执行如下命令,创建Flannel守护进程。(我前面已经安装并导入了Flannel的镜像)

docker load -i flannel-dashboard.tar.gz
[root@k8s-node ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
k8s.gcr.io/kube-proxy v1.14.1 20a2d7035165 months ago .1MB
k8s.gcr.io/kube-apiserver v1.14.1 cfaa4ad74c37 months ago 210MB
k8s.gcr.io/kube-scheduler v1.14.1 8931473d5bdb months ago .6MB
k8s.gcr.io/kube-controller-manager v1.14.1 efb3887b411d months ago 158MB
quay.io/coreos/flannel v0.11.0-amd64 ff281650a721 months ago .6MB
k8s.gcr.io/coredns 1.3. eb516548c180 months ago .3MB
k8s.gcr.io/kubernetes-dashboard-amd64 v1.10.1 f9aed6605b81 months ago 122MB
k8s.gcr.io/etcd 3.3. 2c4adeb21b4f months ago 258MB
k8s.gcr.io/pause 3.1 da86e6ba6ca1 months ago 742kB
kubectl create -f /opt/k8s/kube-flannel.yaml
[root@k8s-node ~]# cat /opt/k8s/kube-flannel.yaml
---
apiVersion: extensions/v1beta1
kind: PodSecurityPolicy
metadata:
name: psp.flannel.unprivileged
annotations:
seccomp.security.alpha.kubernetes.io/allowedProfileNames: docker/default
seccomp.security.alpha.kubernetes.io/defaultProfileName: docker/default
apparmor.security.beta.kubernetes.io/allowedProfileNames: runtime/default
apparmor.security.beta.kubernetes.io/defaultProfileName: runtime/default
spec:
privileged: false
volumes:
- configMap
- secret
- emptyDir
- hostPath
allowedHostPaths:
- pathPrefix: "/etc/cni/net.d"
- pathPrefix: "/etc/kube-flannel"
- pathPrefix: "/run/flannel"
readOnlyRootFilesystem: false
# Users and groups
runAsUser:
rule: RunAsAny
supplementalGroups:
rule: RunAsAny
fsGroup:
rule: RunAsAny
# Privilege Escalation
allowPrivilegeEscalation: false
defaultAllowPrivilegeEscalation: false
# Capabilities
allowedCapabilities: ['NET_ADMIN']
defaultAddCapabilities: []
requiredDropCapabilities: []
# Host namespaces
hostPID: false
hostIPC: false
hostNetwork: true
hostPorts:
- min:
max:
# SELinux
seLinux:
# SELinux is unsed in CaaSP
rule: 'RunAsAny'
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: flannel
rules:
- apiGroups: ['extensions']
resources: ['podsecuritypolicies']
verbs: ['use']
resourceNames: ['psp.flannel.unprivileged']
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- apiGroups:
- ""
resources:
- nodes
verbs:
- list
- watch
- apiGroups:
- ""
resources:
- nodes/status
verbs:
- patch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: flannel
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: flannel
subjects:
- kind: ServiceAccount
name: flannel
namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: flannel
namespace: kube-system
---
kind: ConfigMap
apiVersion: v1
metadata:
name: kube-flannel-cfg
namespace: kube-system
labels:
tier: node
app: flannel
data:
cni-conf.json: |
{
"name": "cbr0",
"plugins": [
{
"type": "flannel",
"delegate": {
"hairpinMode": true,
"isDefaultGateway": true
}
},
{
"type": "portmap",
"capabilities": {
"portMappings": true
}
}
]
}
net-conf.json: |
{
"Network": "10.245.0.0/16",
"Backend": {
"Type": "vxlan"
}
}
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: kube-flannel-ds-amd64
namespace: kube-system
labels:
tier: node
app: flannel
spec:
template:
metadata:
labels:
tier: node
app: flannel
spec:
hostNetwork: true
nodeSelector:
beta.kubernetes.io/arch: amd64
tolerations:
- operator: Exists
effect: NoSchedule
serviceAccountName: flannel
initContainers:
- name: install-cni
image: quay.io/coreos/flannel:v0.11.0-amd64
command:
- cp
args:
- -f
- /etc/kube-flannel/cni-conf.json
- /etc/cni/net.d/-flannel.conflist
volumeMounts:
- name: cni
mountPath: /etc/cni/net.d
- name: flannel-cfg
mountPath: /etc/kube-flannel/
containers:
- name: kube-flannel
image: quay.io/coreos/flannel:v0.11.0-amd64
command:
- /opt/bin/flanneld
args:
- --ip-masq
- --kube-subnet-mgr
resources:
requests:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "100m"
memory: "50Mi"
securityContext:
privileged: false
capabilities:
add: ["NET_ADMIN"]
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumeMounts:
- name: run
mountPath: /run/flannel
- name: flannel-cfg
mountPath: /etc/kube-flannel/
volumes:
- name: run
hostPath:
path: /run/flannel
- name: cni
hostPath:
path: /etc/cni/net.d
- name: flannel-cfg
configMap:
name: kube-flannel-cfg

最新文章

  1. 第三章 EnumUtil根据值获取枚举对象
  2. sql server 2008 不允许保存更改,您所做的更改要求删除并重新创建以下表 的解决办法
  3. 微信、qq时间格式模板
  4. JavaEE SSH框架整合(三) struts2 异常、http错误状态码处理
  5. 7.4.1 Dumping Data in SQL Format with mysqldump
  6. HTML4基础
  7. 实现Spring RESTful服务的SSL
  8. ●BZOJ 2442 [Usaco2011 Open]修剪草坪
  9. 如何安装Magento 2.0
  10. Python---Models 模型
  11. Ubuntu16.04下postgresql-10
  12. ComputeShader中Counter类型的使用
  13. Django中media的配置
  14. mysql开启调试日志general_log开启跟踪日志
  15. 腾讯云YUM安装失效
  16. python-memcached包使用方法
  17. linux环境中,如何解压后缀是bz2的压缩包?tar.bz2格式的压缩包,如何进行解压?
  18. redis mongodb mysql 三大数据库的更简单的批量操作。批量任务自动聚合器。
  19. Android仿淘宝头条滚动广告条
  20. 禁用IE缓存

热门文章

  1. Linux文件系统之mv(重命名/移动文件)
  2. hadoop关闭安全模式
  3. BZOJ 4009: [HNOI2015]接水果 (整体二分+扫描线 树状数组)
  4. 队列BlockingQueue的简单例子
  5. 题解 [CF720A] Closing ceremony
  6. 【转】pe结构详解
  7. Bert系列 源码解读 四 篇章
  8. python 绘制f(x)=x^2
  9. CF1204A
  10. Dubbo系列(一)dubbo的产生背景与原理概述