溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Rancher 2.x,K8S,使用問題記錄(持續(xù)更新.)

發(fā)布時間:2020-07-26 07:57:40 來源:網(wǎng)絡(luò) 閱讀:843 作者:槑槑的嫑嫑 欄目:云計算

1、ingress-nginx,修改默認的Nginx上傳大?。?/h3>

使用Rancher的負載均衡,上傳1M以上的文件報錯,查看ingress-nginx容器,發(fā)現(xiàn)配置

client_max_body_size 1m;

解決辦法:

創(chuàng)建ingress的時候修改參數(shù):


apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/proxy-body-size: 50m

2、k8s使用cronjob自動備份gitlab

常規(guī)情況為使用定時任務(wù)運行腳本,運行命令即可

gitlab-rake gitlab:backup:create

k8s中運行的gitlab,使用cronjob定時運行腳本即可:

1、為了可以使用kubectl,需要使用kubeconfig,創(chuàng)建configmap 就叫kubeconfig:

#kubeconfig默認放在/root/.kube/config

kubectl create configmap kubeconfig -n gitlab --from-file=/root/.kube/config

2、創(chuàng)建備份腳本,configmap:

備份腳本如下:

#!/bin/sh

pod_name=$(kubectl get pods -l app=gitlab -o jsonpath={.items[*].metadata.name} -n gitlab --kubeconfig=/etc/kubeconfig/config)

kubectl --kubeconfig=/etc/kubeconfig/config exec $pod_name -n gitlab -- gitlab-rake gitlab:backup:create

導(dǎo)入到configmap

3、掛載兩個configmap,需要放到對應(yīng)路徑,kubeconfig放到/etc/kubeconfig/config,備份腳本放到運行路徑下即可

4、配置cronjob定時運行掛載的腳本即可

apiVersion: v1
items:

  • apiVersion: batch/v1beta1
    kind: CronJob
    metadata:
    name: gitlab2-backup
    namespace: gitlab
    spec:
    concurrencyPolicy: Allow
    failedJobsHistoryLimit: 10
    jobTemplate:
    metadata:
    creationTimestamp: null
    spec:
    template:
    metadata:
    spec:
    containers:
    • command:
      • sh
      • /home/demo.sh
        image: lachlanevenson/k8s-kubectl:v1.17.0
        imagePullPolicy: IfNotPresent
        name: gitlab2-backup
        resources: {}
        stdin: true
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        tty: true
        volumeMounts:
      • mountPath: /etc/kubeconfig
        name: vol1
      • mountPath: /home
        name: vol2
        volumes:
    • configMap:
      defaultMode: 420
      name: kubeconfig
      optional: false
      name: vol1
    • configMap:
      defaultMode: 493
      name: backup-config
      optional: false
      name: vol2
      schedule: 25 8 *
      successfulJobsHistoryLimit: 10
      suspend: false
      kind: List
      metadata:
      resourceVersion: ""
      selfLink: ""

3、Rancher新增加節(jié)點報錯

Runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized

查看發(fā)現(xiàn)新節(jié)點/etc/cni/net.d/下無配置文件,把其他的節(jié)點的配置文件拷貝過來即可

10-canal.conflist calico-kubeconfig

雖然節(jié)點顯示正常了不過運行容器報錯:

Failed create pod sandbox: rpc error: code = Unknown desc = [failed to set up sandbox container "75b6c96ee03bcdb754b01c126afb8f77016000a27e1ad7d55bd4d1e31c7889c4" network for pod "demo1111-645996f944-lrkwq": NetworkPlugin cni failed to set up pod "demo1111-645996f944-lrkwq_yj-test" network: failed to find plugin "loopback" in path [/opt/cni/bin], failed to clean up sandbox container "75b6c96ee03bcdb754b01c126afb8f77016000a27e1ad7d55bd4d1e31c7889c4" network for pod "demo1111-645996f944-lrkwq": NetworkPlugin cni failed to teardown pod "demo1111-645996f944-lrkwq_yj-test" network: failed to find plugin "portmap" in path [/opt/cni/bin]] 2 minutes ago

Warning FailedCreatePodSandBox Failed create pod sandbox: rpc error: code = Unknown desc = [failed to set up sandbox container

查看/opt/cni/bin,果然也沒有相關(guān)文件,同上把其他節(jié)點的拷貝過來

可是感覺應(yīng)該不會莫名的沒有安裝上,查看rancher system項目,發(fā)現(xiàn)kube-system空間下的canal在node3還未成功啟動,在查看原來是相關(guān)鏡像拉取較慢。。鏡像拉取成功后(我是手動導(dǎo)的)即一切正常。

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI