微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Rancher 2.x,K8S,使用问题记录持续更新.)

1、ingress-Nginx,修改认的Nginx上传大小:

使用Rancher的负载均衡上传1M以上的文件报错,查看ingress-Nginx容器,发现配置

client_max_body_size 1m;

解决办法:

创建ingress的时候修改参数:


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

2、k8s使用cronjob自动备份gitlab

常规情况为使用定时任务运行脚本,运行命令即可

gitlab-rake gitlab:backup:create

k8s中运行的gitlab,使用cronjob定时运行脚本即可:

1、为了可以使用kubectl,需要使用kubeconfig,创建configmap 就叫kubeconfig

#kubeconfig认放在/root/.kube/config

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

2、创建备份脚本,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

导入到configmap

3、挂载两个configmap,需要放到对应路径,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新增加节点报错

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

查看发现新节点/etc/cni/net.d/下无配置文件,把其他的节点的配置文件拷贝过来即可

10-canal.conflist calico-kubeconfig

虽然节点显示正常了不过运行容器报错:

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,果然也没有相关文件,同上把其他节点的拷贝过来

可是感觉应该不会莫名的没有安装上,查看rancher system项目,发现kube-system空间下的canal在node3还未成功启动,在查看原来是相关镜像拉取较慢。。镜像拉取成功后(我是手动导的)即一切正常。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐