kubeedge 二进制安装与 keadm 工具安装

方法1:

1.配置master

wget https://github.com/kubeedge/kubeedge/releases/download/v1.12.1/keadm-v1.12.1-linux-amd64.tar.gz
tar -zxvf keadm-v1.12.1-linux-amd64.tar.gz
​
cp keadm-v1.12.1-linux-amd64/keadm/keadm /usr/local/bin/keadm
​
keadm init --advertise-address="123.249.101.186" --profile version=v1.12.1 --kube-config=/root/.kube/config
Kubernetes version verification passed, KubeEdge installation will start...
CLOUDCORE started
=========CHART DETAILS=======
NAME: cloudcore
LAST DEPLOYED: Wed Oct 26 11:10:04 2022
NAMESPACE: kubeedge
STATUS: deployed
REVISION: 1
​
# 配置kube-proxy  让边缘节点不部署kube-proxy 
kubectl patch daemonset kube-proxy -n kube-system -p '{"spec": {"template": {"spec": {"affinity": {"nodeAffinity": {"requiredDuringSchedulingIgnoredDuringExecution": {"nodeSelectorTerms": [{"matchExpressions": [{"key": "node-role.kubernetes.io/edge", "operator": "DoesNotExist"}]}]}}}}}}}'
​
keadm gettoken

2.配置边缘工作节点

keadm join --cloudcore-ipport=123.249.101.182:10000 --token=63441de86420824149c56edc4410e780f978a17ddfa9654596d7aed757af146b.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MDE3NTM2OTJ9.jiy1mXFVNSS5NvmRNHdD4r8UOVWxtNqHVmgz6Altr_Y --kubeedge-version=v1.11.1
systemctl status 

3.master

# 在master 上查看可以发现已经加入成功了

[root@k8s-master ~]# kubectl get node
NAME                    STATUS   ROLES           AGE   VERSION
k8s-master              Ready    control-plane   17h   v1.27.3
localhost.localdomain   Ready    agent,edge      41s   v1.22.6-kubeedge-v1.12.1

4.配置Metrics

git clone https://github.com/kubernetes-sigs/metrics-server.git
cd metrics-server
make container
# 查看镜像是否存在
docker images
#设置iptables
iptables -t nat -A OUTPUT -p tcp --dport 10350 -j DNAT --to $CLOUDCOREIPS:10003
iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X
​# 清除master点的污点(可不操作)
kubectl taint nodes --all node-role.kubernetes.io/master-
​
kubectl apply -f deployment.yaml

方法2:

1.云端

选择离线安装包,因为国内可能拉不到
现在下载好你想安装的版本,并上传
​
tar -zxvf /opt/kubeedge/kubeedge-1.11.1.tar.gz
cp -rvf /opt/kubeedge/kubeedge-v1.11.1-linux-amd64.tar.gz  /etc/kubeedge/
cp -rvf /opt/kubeedge/kubeedge-1.11.1/build/crds/   /etc/kubeedge/
cp -rvf /opt/kubeedge/kubeedge-1.11.1/vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/checksum /etc/kubeedge/
cp /opt/kubeedge/kubeedge-1.11.1/build/tools/cloudcore.service /etc/kubeedge/
​
​
cd /etc/kubeedge/
​
​
keadm deprecated   init --advertise-address=$master_ip --kubeedge-version=1.11.1
ss -ntpl
​
#启用systemd 管理
cp /etc/kubeedge/cloudcore.service /etc/systemd/system/cloudcore.service
chmod +x /etc/systemd/system/cloudcore.service
systemctl daemon-reload
ps aux | grep cloudcore
pid=$(ps aux | grep cloudcore | awk 'NR==1{print $2}')
kill -9 $pid
systemctl start cloudcore
systemctl enable cloudcore.service
systemctl status cloudcore
​
​
生成证书:
ls /etc/kubernetes/pki/
export CLOUDCOREIPS=$master_ip
echo $CLOUDCOREIPS
cd /opt/kubeedge/kubeedge-1.11.1/build/tools/
./certgen.sh stream
​
配置边缘节点不部署kube-proxy
kubectl patch daemonset kube-proxy -n kube-system -p '{"spec": {"template": {"spec": {"affinity": {"nodeAffinity": {"requiredDuringSchedulingIgnoredDuringExecution": {"nodeSelectorTerms": [{"matchExpressions": [{"key": "node-role.kubernetes.io/edge", "operator": "DoesNotExist"}]}]}}}}}}}'
​
​
清除 iptables 的所有规则和链
iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X
​
​
keadm gettoken
​
kubectl label node k8s-master node-role.kubernetes.io/master=''
​

2.边缘端

keadm 与master 的版本要一至
wget https://github.com/kubeedge/kubeedge/releases/download/v1.12.1/keadm-v1.12.1-linux-amd64.tar.gz
​
​
yum -y install docker-ce
systemctl restart docker
docker --version
​
mv /opt/kubeedge/keadm /usr/bin/
​
cd /opt/kubeedge
​
keadm join --cloudcore-ipport=$master_ip:10000 --token=$token
​
systemctl start edgecore
systemctl status edgecore
​
​

3.配置Metrics ,和上面一样,这是修改好后的完整yaml

kubectl apply -f deploy.yaml 
[root@k8s-master opt]# cat deploy.yaml 
apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    k8s-app: metrics-server
    rbac.authorization.k8s.io/aggregate-to-admin: "true"
    rbac.authorization.k8s.io/aggregate-to-edit: "true"
    rbac.authorization.k8s.io/aggregate-to-view: "true"
  name: system:aggregated-metrics-reader
rules:
- apiGroups:
  - metrics.k8s.io
  resources:
  - pods
  - nodes
  verbs:
  - get
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    k8s-app: metrics-server
  name: system:metrics-server
rules:
- apiGroups:
  - ""
  resources:
  - pods
  - nodes
  - nodes/stats
  - namespaces
  - configmaps
  verbs:
  - get
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server-auth-reader
  namespace: kube-system
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: extension-apiserver-authentication-reader
subjects:
- kind: ServiceAccount
  name: metrics-server
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server:system:auth-delegator
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: system:auth-delegator
subjects:
- kind: ServiceAccount
  name: metrics-server
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:
    k8s-app: metrics-server
  name: system:metrics-server
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: system:metrics-server
subjects:
- kind: ServiceAccount
  name: metrics-server
  namespace: kube-system
---
apiVersion: v1
kind: Service
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server
  namespace: kube-system
spec:
  ports:
  - name: https
    port: 443
    protocol: TCP
    targetPort: https
  selector:
    k8s-app: metrics-server
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server
  namespace: kube-system
spec:
  selector:
    matchLabels:
      k8s-app: metrics-server
  strategy:
    rollingUpdate:
      maxUnavailable: 0
  template:
    metadata:
      labels:
        k8s-app: metrics-server
    spec:
      hostNetwork: true
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: node-role.kubernetes.io/master
                operator: Exists
      tolerations:
      - key: node-role.kubernetes.io/master
        operator: Exists
        effect: NoSchedule
      containers:
      - args:
        - --kubelet-insecure-tls
        - --cert-dir=/tmp
        - --secure-port=4443
        - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
        - --kubelet-use-node-status-port
        image: bitnami/metrics-server:0.4.0
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /livez
            port: https
            scheme: HTTPS
          periodSeconds: 10
        name: metrics-server
        ports:
        - containerPort: 4443
          name: https
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /readyz
            port: https
            scheme: HTTPS
          periodSeconds: 10
        securityContext:
          readOnlyRootFilesystem: true
          runAsNonRoot: true
          runAsUser: 1000
        volumeMounts:
        - mountPath: /tmp
          name: tmp-dir
      nodeSelector:
        kubernetes.io/os: linux
      priorityClassName: system-cluster-critical
      serviceAccountName: metrics-server
      volumes:
      - emptyDir: {}
        name: tmp-dir
---
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
  labels:
    k8s-app: metrics-server
  name: v1beta1.metrics.k8s.io
spec:
  group: metrics.k8s.io
  groupPriorityMinimum: 100
  insecureSkipTLSVerify: true
  service:
    name: metrics-server
    namespace: kube-system
  version: v1beta1
  versionPriority: 100

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值