Clever Castle
181 words
1 minutes
k8s 踩坑

Kustomize#

SecretGenerator 用于环境变量中#

方法1#

secretGenerator:
    -   name: props
        literals:
            - database-url=mongodb://mongodb-service-local.mongodb-local:27017/app

# patch

apiVersion: apps/v1
kind: Deployment
metadata:
    name: app
spec:
    template:
        spec:
            containers:
                -   name: app
                    image: app:latest
                    envFrom:
                        -   secretRef:
                                name: props

这样子会将database-url添加到环境变量中,没有问题

方法2#

# file conf.properties

database-url=mongodb://mongodb-service-local.mongodb-local:27017/ap
secretGenerator:
    -   name: props
        files:
            - conf.properties

# patch

apiVersion: apps/v1
kind: Deployment
metadata:
    name: app
spec:
    template:
        spec:
            containers:
                -   name: app
                    image: app:latest
                    envFrom:
                        -   secretRef:
                                name: props

这样做就会有问题, 它在环境变量中生成的值类似于下值

conf.properties=database-url=mongodb://mongodb-service-local.mongodb-local:27017/ap

这样并不符合预期

k3s 重启机器状态为NotReady#

发现 /etc/cni/net.d为空,所以cp /var/lib/rancher/k3s/agent/etc/cni/net.d/10-flannel.conflist /etc/cni/net.d/

参见一下两个issue

Agent status become Not_Ready after reboot · Issue #4113 · k3s-io/k3s

runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized · Issue #1031 · kubernetes/kubeadm

k8s 踩坑
https://blog.ivyxjc.com/posts/k8s-issue/
Author
ivyxjc
Published at
2021-10-04