首页 > 其他分享 >安装pod网络插件flannel

安装pod网络插件flannel

时间:2022-10-21 18:44:23浏览次数:118  
标签:插件 name flannel metadata io pod kube cni

官网地址

https://github.com/flannel-io/flannel/blob/master/Documentation/kube-flannel.yml

感觉网络这块有点复杂,抠脑壳!!

同一个节点上宿pod之间同通信
不同节点上pod之间通信等等

https://zhuanlan.zhihu.com/p/140711132
https://blog.csdn.net/inthat/article/details/103921026

一、下载flannel

#去官网下载yaml文件,我这里是直接复制了
# 创建kube-flannel.yml,把下面内容复制进行

---
kind: Namespace
apiVersion: v1
metadata:
  name: kube-flannel
  labels:
    pod-security.kubernetes.io/enforce: privileged
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: flannel
rules:
- apiGroups:
  - ""
  resources:
  - pods
  verbs:
  - get
- apiGroups:
  - ""
  resources:
  - nodes
  verbs:
  - list
  - watch
- apiGroups:
  - ""
  resources:
  - nodes/status
  verbs:
  - patch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: flannel
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: flannel
subjects:
- kind: ServiceAccount
  name: flannel
  namespace: kube-flannel
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: flannel
  namespace: kube-flannel
---
kind: ConfigMap
apiVersion: v1
metadata:
  name: kube-flannel-cfg
  namespace: kube-flannel
  labels:
    tier: node
    app: flannel
data:
  cni-conf.json: |
    {
      "name": "cbr0",
      "cniVersion": "0.3.1",
      "plugins": [
        {
          "type": "flannel",
          "delegate": {
            "hairpinMode": true,
            "isDefaultGateway": true
          }
        },
        {
          "type": "portmap",
          "capabilities": {
            "portMappings": true
          }
        }
      ]
    }
  net-conf.json: |
    {
      "Network": "10.244.0.0/16",
      "Backend": {
        "Type": "vxlan"
      }
    }
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: kube-flannel-ds
  namespace: kube-flannel
  labels:
    tier: node
    app: flannel
spec:
  selector:
    matchLabels:
      app: flannel
  template:
    metadata:
      labels:
        tier: node
        app: flannel
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/os
                operator: In
                values:
                - linux
      hostNetwork: true
      priorityClassName: system-node-critical
      tolerations:
      - operator: Exists
        effect: NoSchedule
      serviceAccountName: flannel
      initContainers:
      - name: install-cni-plugin
       #image: flannelcni/flannel-cni-plugin:v1.1.0 for ppc64le and mips64le (dockerhub limitations may apply)
        image: docker.io/rancher/mirrored-flannelcni-flannel-cni-plugin:v1.1.0
        command:
        - cp
        args:
        - -f
        - /flannel
        - /opt/cni/bin/flannel
        volumeMounts:
        - name: cni-plugin
          mountPath: /opt/cni/bin
      - name: install-cni
       #image: flannelcni/flannel:v0.20.0 for ppc64le and mips64le (dockerhub limitations may apply)
        image: docker.io/rancher/mirrored-flannelcni-flannel:v0.20.0
        command:
        - cp
        args:
        - -f
        - /etc/kube-flannel/cni-conf.json
        - /etc/cni/net.d/10-flannel.conflist
        volumeMounts:
        - name: cni
          mountPath: /etc/cni/net.d
        - name: flannel-cfg
          mountPath: /etc/kube-flannel/
      containers:
      - name: kube-flannel
       #image: flannelcni/flannel:v0.20.0 for ppc64le and mips64le (dockerhub limitations may apply)
        image: docker.io/rancher/mirrored-flannelcni-flannel:v0.20.0
        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", "NET_RAW"]
        env:
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: EVENT_QUEUE_DEPTH
          value: "5000"
        volumeMounts:
        - name: run
          mountPath: /run/flannel
        - name: flannel-cfg
          mountPath: /etc/kube-flannel/
        - name: xtables-lock
          mountPath: /run/xtables.lock
      volumes:
      - name: run
        hostPath:
          path: /run/flannel
      - name: cni-plugin
        hostPath:
          path: /opt/cni/bin
      - name: cni
        hostPath:
          path: /etc/cni/net.d
      - name: flannel-cfg
        configMap:
          name: kube-flannel-cfg
      - name: xtables-lock
        hostPath:
          path: /run/xtables.lock
          type: FileOrCreate

二、安装

kubectl apply -f kube-flannel.yml

标签:插件,name,flannel,metadata,io,pod,kube,cni
From: https://www.cnblogs.com/bangbangzoutianya/p/16814464.html

相关文章

  • 创建Pod的YAML文件内的结构
    创建K8S的YAML文件内的结构yaml编写规则大小写敏感使用缩进表示层级关系缩进时不允许使用Tal键,只允许使用空格缩进的空格数目不重要,只要相同层级的元素左侧对齐即可......
  • 【Jmeter】Jmeter插件下载
    0、插件下载地址: https://jmeter-plugins.org/install/Install/  1、将插件放在Jmeter文件夹内/lib/etc文件夹下    2、重启Jmeter   3、点击插件管......
  • docker/podman
    虚拟化技术虚拟化技术:把真实物理机子中剩余的资源重新整合,基于虚拟机软件创建出来一台新的虚拟的计算机提供给开发者使用。优点:虚拟化使用软件/硬件的方法重新定义......
  • Chrome 浏览器安装Vue插件方法
    谷歌浏览器扩展程序 首先去github下载vue.zip文件插件 下载地址:https://github.com/vuejs/vue-devtools不要去下载默认分支的 下载后解压验证npm是否安装成......
  • LyScript 插件实现UPX脱壳
    LyScript插件可实现对压缩壳的快速脱壳操作,目前支持两种脱壳方式,一种是运用API接口自己编写脱壳过程,另一种是直接加载现有的脱壳脚本运行脱壳。LyScript项目地址:​​http......
  • 集成 Maven 2 插件到 Eclipse 的过程
        前言    本文使用的不是在线方式安装Maven插件,用的是link方式。之所以使用link方式,是为了可以方便对Eclipse插件的管......
  • dremio 存储插件之StoragePluginRulesFactory 类简单说明
    StoragePluginRulesFactory是dremio为了分离每个插件的规则,我们存储插件可以包含自己的规则工厂,具体使用到StoragePluginRulesFactory的包含了CatalogServiceImpl,SqlHa......
  • 集成 CDT 插件至 Eclipse 全过程,并开发你第一个 Eclipse 下的 C/C++ 程序
    集成CDT插件至Eclipse全过程,并开发你第一个Eclipse下的C/C++程序本文示例用CDT插件已经上传,​​点击这里进入下载页面​​。       集成CDT插件至Ecl......
  • 插件遇到的问题
    1.ng2-dragula插入新数据之后再拖拽,数据总是显示在最上面https://stackoverflow.com/questions/63532041/ng2-dragula-after-adding-new-item-its-getting-displayed-at......
  • k8s基础篇 pod(四)标签
    4.1什么是标签?标签其实就一对key/value,被关联到对象上,比如Pod,标签的使用我们倾向于能够表示对象的特殊特点,就是一眼就看出了这个Pod是干什么的,标签可以用来划分特定的对......