k8s 二进制部署 (四)
上一节部署完matser 并进行了RBAC 授权,可以通过kubectl get no 看到三台master,都是NotReady状态,这是因为没有部署网络插件,k8s没部署网络插件之前节点是NotReady的
这一节部署网络插件(flannel vxlan 模式):
记集群POD网段为 :
CLUSTER_CIDR=10.10.0.0/16
cat <<EOF | tee kube-flannel.yml---apiVersion: policy/v1beta1kind: PodSecurityPolicymetadata:name: psp.flannel.unprivilegedannotations:: docker/default: docker/default: runtime/default: runtime/defaultspec:privileged: falsevolumes:configMapsecretemptyDirhostPathallowedHostPaths:pathPrefix: "/etc/cni/net.d"pathPrefix: "/etc/kube-flannel"pathPrefix: "/run/flannel"readOnlyRootFilesystem: false# Users and groupsrunAsUser:rule: RunAsAnysupplementalGroups:rule: RunAsAnyfsGroup:rule: RunAsAny# Privilege EscalationallowPrivilegeEscalation: falsedefaultAllowPrivilegeEscalation: false# CapabilitiesallowedCapabilities: ['NET_ADMIN', 'NET_RAW']defaultAddCapabilities: []requiredDropCapabilities: []# Host namespaceshostPID: falsehostIPC: falsehostNetwork: truehostPorts:min: 0max: 65535# SELinuxseLinux:# SELinux is unused in CaaSPrule: 'RunAsAny'---kind: ClusterRoleapiVersion: rbac.authorization.k8s.io/v1metadata:name: flannelrules:apiGroups: ['extensions']resources: ['podsecuritypolicies']verbs: ['use']resourceNames: ['psp.flannel.unprivileged']apiGroups:""resources:podsverbs:getapiGroups:""resources:nodesverbs:listwatchapiGroups:""resources:nodes/statusverbs:patch---kind: ClusterRoleBindingapiVersion: rbac.authorization.k8s.io/v1metadata:name: flannelroleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: flannelsubjects:kind: ServiceAccountname: flannelnamespace: kube-system---apiVersion: v1kind: ServiceAccountmetadata:name: flannelnamespace: kube-system---kind: ConfigMapapiVersion: v1metadata:name: kube-flannel-cfgnamespace: kube-systemlabels:tier: nodeapp: flanneldata:: |{: "cbr0",: "0.3.1",: [{: "flannel",: {: true,: true}},{: "portmap",: {: true}}]}: |{: "10.10.0.0/16",: {: "vxlan"}}---apiVersion: apps/v1kind: DaemonSetmetadata:name: kube-flannel-dsnamespace: kube-systemlabels:tier: nodeapp: flannelspec:selector:matchLabels:app: flanneltemplate:metadata:labels:tier: nodeapp: flannelspec:affinity:nodeAffinity:requiredDuringSchedulingIgnoredDuringExecution:nodeSelectorTerms:matchExpressions:key: kubernetes.io/osoperator: Invalues:linuxhostNetwork: truepriorityClassName: system-node-criticaltolerations:operator: Existseffect: NoScheduleserviceAccountName: flannelinitContainers:name: install-cni-pluginimage: rancher/mirrored-flannelcni-flannel-cni-plugin:v1.0.0command:cpargs:-f/flannel/opt/cni/bin/flannelvolumeMounts:name: cni-pluginmountPath: /opt/cni/binname: install-cniimage: rancher/mirrored-flannelcni-flannel:v0.16.1command:cpargs:-f/etc/kube-flannel/cni-conf.json/etc/cni/net.d/10-flannel.conflistvolumeMounts:name: cnimountPath: /etc/cni/net.dname: flannel-cfgmountPath: /etc/kube-flannel/containers:name: kube-flannelimage: rancher/mirrored-flannelcni-flannel:v0.16.1command:/opt/bin/flanneldargs:--ip-masq--kube-subnet-mgrresources:requests:cpu: "100m"memory: "50Mi"limits:cpu: "100m"memory: "50Mi"securityContext:privileged: falsecapabilities:add: ["NET_ADMIN", "NET_RAW"]env:name: POD_NAMEvalueFrom:fieldRef:fieldPath: metadata.namename: POD_NAMESPACEvalueFrom:fieldRef:fieldPath: metadata.namespacevolumeMounts:name: runmountPath: /run/flannelname: flannel-cfgmountPath: /etc/kube-flannel/volumes:name: runhostPath:path: /run/flannelname: cni-pluginhostPath:path: /opt/cni/binname: cnihostPath:path: /etc/cni/net.dname: flannel-cfgconfigMap:name: kube-flannel-cfgEOF
kubectl apply -f kube-flannel.yml
部署完网络插件可以 再get node 就是 Ready状态了
