如何使用Minikube设置imagePullPolicy

Ala*_*orm 1 kubernetes minikube

我是Kubernetes的新手.我正在尝试按照本教程指导我如何使用minikube设置本地服务.我能够$ kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.10 --port=8080从教程中获得运行服务的东西.好哇!

现在我想运行一个带有本地标记和构建的 Docker镜像的服务器.根据这篇文章,我需要做的就是告诉我的电脑使用minikube docker守护进程,构建我的图像,然后设置imagePullPolicy为never.

如何和我在哪里设置imagePullPolicyminikube?我已经google了一下,虽然有很多结果,但我在K8的"树林里的宝贝"状态会导致信息过载.(即你的答案越简单越好)

Ric*_*ico 9

您必须编辑部署(kubectl run创建部署).规范看起来像这样:

spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      run: hello-minikube
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        run: hello-minikube
    spec:
      containers:
      - image: k8s.gcr.io/echoserver:1.10 <-- change to the right image
        imagePullPolicy: IfNotPresent <-- change to Always
        name: hello-minikube
        ports:
        - containerPort: 8080
          protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
Run Code Online (Sandbox Code Playgroud)

编辑:

$ kubectl edit deployment hello-minikube
Run Code Online (Sandbox Code Playgroud)