K8S相关问题解决

本文主要记录了工作中解决的一些K8S相关的问题,本人是K8S小白,后面会专门抽出时间来学习K8S的

1、imagePullPolicy拉取策略

  • Always:总是去镜像仓库拉取
  • IfNotPresent:本地有则使用本地镜像,否则去镜像仓库拉取
  • Never:只使用本地镜像,从不拉取

2、K8S向Pod里的/etc/hosts添加条目

apiVersion: v1
kind: Pod
metadata:
  name: hostaliases-pod
spec:
  restartPolicy: Never
  hostAliases:
  - ip: "127.0.0.1"
    hostnames:
    - "foo.local"
    - "bar.local"
  - ip: "10.1.2.3"
    hostnames:
    - "foo.remote"
    - "bar.remote"
  containers:
  - name: cat-hosts
    image: busybox
    command:
    - cat
    args:
    - "/etc/hosts"

官方文档地址:https://kubernetes.io/zh/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/

猜你喜欢

转载自blog.csdn.net/qq_40378034/article/details/107619736