我刚开始的 ssm-deployment.yml 文件如下
使用 kubectl get deploy 结果如下
居然没有起来 因为我 pull 和push 镜像都没有问题 。然后我看 具体的Pod的状态如下
Failed to pull image "10.136.195.150:80/micro/ssm:latest": rpc error: code =
Unknown desc = Error response from daemon: pull access denied for 10.136.195.150:80/micro/ssm, repository does not exist or may require ‘do
cker login‘
可是 我已经登录 我自己的 私有仓库了啊
经过百度 发现需要配置 secret
命令如下
然后在 ssm-deployment.yml 中引用这个 secret 就可以了
[[email protected] ~]# kubectl get secretsNAME TYPE DATA AGEdefault-token-77vdj kubernetes.io/service-account-token 3 40h[[email protected] ~]# vi ssm-deployment.yml [[email protected] ~]# kubectl get deployNAME READY UP-TO-DATE AVAILABLE AGEkubernetes-bootcamp 1/1 1 1 26hnginx-deployment 2/2 2 2 26hssm-deployment 0/2 2 0 46m[[email protected] ~]# kubectl delete deploy ssm-deploymentdeployment.extensions "ssm-deployment" deleted[[email protected] ~]# kubectl apply -f ssm-deployment.yml deployment.apps/ssm-deployment created[[email protected] ~]# kubectl get deployNAME READY UP-TO-DATE AVAILABLE AGEkubernetes-bootcamp 1/1 1 1 26hnginx-deployment 2/2 2 2 26hssm-deployment 0/2 2 0 9s[[email protected] ~]# kubectl get deployNAME READY UP-TO-DATE AVAILABLE AGEkubernetes-bootcamp 1/1 1 1 26hnginx-deployment 2/2 2 2 26hssm-deployment 0/2 2 0 14s[[email protected] ~]# kubectl get podsNAME READY STATUS RESTARTS AGEkubernetes-bootcamp-76fcb8587-cd7s7 1/1 Running 1 26hnginx-deployment-5754944d6c-pf256 1/1 Running 1 26hnginx-deployment-5754944d6c-r7ths 1/1 Running 1 26hssm-deployment-855cd7f589-48qcg 0/1 InvalidImageName 0 20sssm-deployment-855cd7f589-skmxx 0/1 InvalidImageName 0 20s[[email protected] ~]# kubectl get podsNAME READY STATUS RESTARTS AGEkubernetes-bootcamp-76fcb8587-cd7s7 1/1 Running 1 26hnginx-deployment-5754944d6c-pf256 1/1 Running 1 26hnginx-deployment-5754944d6c-r7ths 1/1 Running 1 26hssm-deployment-855cd7f589-48qcg 0/1 InvalidImageName 0 30sssm-deployment-855cd7f589-skmxx 0/1 InvalidImageName 0 30s[[email protected] ~]# [[email protected] ~]# kubectl get podsNAME READY STATUS RESTARTS AGEkubernetes-bootcamp-76fcb8587-cd7s7 1/1 Running 1 26hnginx-deployment-5754944d6c-pf256 1/1 Running 1 26hnginx-deployment-5754944d6c-r7ths 1/1 Running 1 26hssm-deployment-855cd7f589-48qcg 0/1 InvalidImageName 0 34sssm-deployment-855cd7f589-skmxx 0/1 InvalidImageName 0 34s[[email protected] ~]# kubectl get podsNAME READY STATUS RESTARTS AGEkubernetes-bootcamp-76fcb8587-cd7s7 1/1 Running 1 26hnginx-deployment-5754944d6c-pf256 1/1 Running 1 26hnginx-deployment-5754944d6c-r7ths 1/1 Running 1 26hssm-deployment-855cd7f589-48qcg 0/1 InvalidImageName 0 36sssm-deployment-855cd7f589-skmxx 0/1 InvalidImageName 0 36s[[email protected] ~]# kubectl describe pod ssm-deployment-855cd7f589-skmxxName: ssm-deployment-855cd7f589-skmxxNamespace: defaultPriority: 0Node: node1/10.136.195.150Start Time: Thu, 14 Nov 2019 11:31:45 +0800Labels: app=ssm-service pod-template-hash=855cd7f589Annotations: <none>Status: PendingIP: 10.244.1.47Controlled By: ReplicaSet/ssm-deployment-855cd7f589Containers: ssm: Container ID: Image: http://10.136.195.150:80/micro/ssm:latest Image ID: Port: 8070/TCP Host Port: 0/TCP State: Waiting Reason: InvalidImageName Ready: False Restart Count: 0 Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from default-token-77vdj (ro)Conditions: Type Status Initialized True Ready False ContainersReady False PodScheduled True Volumes: default-token-77vdj: Type: Secret (a volume populated by a Secret) SecretName: default-token-77vdj Optional: falseQoS Class: BestEffortNode-Selectors: <none>Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s node.kubernetes.io/unreachable:NoExecute for 300sEvents: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 60s default-scheduler Successfully assigned default/ssm-deployment-855cd7f589-skmxx to node1 Warning InspectFailed 2s (x6 over 59s) kubelet, node1 Failed to apply default image tag "http://10.136.195.150:80/micro/ssm:latest": couldn‘t parse image reference "http://10.136.195.150:80/micro/ssm:latest": invalid reference format Warning Failed 2s (x6 over 59s) kubelet, node1 Error: InvalidImageName[[email protected] ~]# kubectl get deployNAME READY UP-TO-DATE AVAILABLE AGEkubernetes-bootcamp 1/1 1 1 26hnginx-deployment 2/2 2 2 26hssm-deployment 0/2 2 0 95s[[email protected] ~]# kubectl delete deploy ssm-deploymentdeployment.extensions "ssm-deployment" deleted[[email protected] ~]# vi ssm-deployment.yml [[email protected] ~]# kubectl apply -f ssm-deployment.yml deployment.apps/ssm-deployment created[[email protected] ~]# kubectl get deployNAME READY UP-TO-DATE AVAILABLE AGEkubernetes-bootcamp 1/1 1 1 26hnginx-deployment 2/2 2 2 26hssm-deployment 0/2 2 0 7s[[email protected] ~]# kubectl get deployNAME READY UP-TO-DATE AVAILABLE AGEkubernetes-bootcamp 1/1 1 1 26hnginx-deployment 2/2 2 2 26hssm-deployment 0/2 2 0 11s[[email protected] ~]# kubectl get deployNAME READY UP-TO-DATE AVAILABLE AGEkubernetes-bootcamp 1/1 1 1 26hnginx-deployment 2/2 2 2 26hssm-deployment 0/2 2 0 13s[[email protected] ~]# kubectl get podsNAME READY STATUS RESTARTS AGEkubernetes-bootcamp-76fcb8587-cd7s7 1/1 Running 1 26hnginx-deployment-5754944d6c-pf256 1/1 Running 1 26hnginx-deployment-5754944d6c-r7ths 1/1 Running 1 26hssm-deployment-5959dfbb8b-cls58 0/1 ErrImagePull 0 18sssm-deployment-5959dfbb8b-hcwhf 0/1 ErrImagePull 0 18s[[email protected] ~]# bubectl describe pod ssm-deployment-5959dfbb8b-cls58-bash: bubectl: command not found[[email protected] ~]# kubectl describe pod ssm-deployment-5959dfbb8b-cls58Name: ssm-deployment-5959dfbb8b-cls58Namespace: defaultPriority: 0Node: node1/10.136.195.150Start Time: Thu, 14 Nov 2019 11:35:34 +0800Labels: app=ssm-service pod-template-hash=5959dfbb8bAnnotations: <none>Status: PendingIP: 10.244.1.49Controlled By: ReplicaSet/ssm-deployment-5959dfbb8bContainers: ssm: Container ID: Image: micro/ssm:latest Image ID: Port: 8070/TCP Host Port: 0/TCP State: Waiting Reason: ErrImagePull Ready: False Restart Count: 0 Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from default-token-77vdj (ro)Conditions: Type Status[[email protected] ~]# kubectl create secret docker-registry regsecret --docker-server=registry.cn-hangzhou.aliyuncs.com [email protected] --docker-password=xxxxxx [email protected]/regsecret created[[email protected] ~]# [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# 作者:殷临风-bash: 作者:殷临风: command not found[[email protected] ~]# 链接:https://www.jianshu.com/p/fd13c2762d81-bash: 链接:https://www.jianshu.com/p/fd13c2762d81: No such file or directory[[email protected] ~]# 来源:简书-bash: 来源:简书: command not found ^C[[email protected] ~]# kubectl create secret docker-registry regsecret --docker-server=registry.cn-hangzhou.aliyuncs.com --docker-username=yin321Error: required flag(s) "docker-password" not set
Examples:[[email protected] ~]# kubectl create secret docker-registry regsecret --docker-server=10.136.195.150:80 --docker-username=adminError: required flag(s) "docker-password" not set
Examples: # If you don‘t already have a .dockercfg file, you can create a dockercfg secret directly by using: kubectl create secret docker-registry my-secret --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL
Options: --allow-missing-template-keys=true: If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. --append-hash=false: Append a hash of the secret to its name. --docker-email=‘‘: Email for Docker registry --docker-password=‘‘: Password for Docker registry authentication --docker-server=‘https://index.docker.io/v1/‘: Server location for Docker registry --docker-username=‘‘: Username for Docker registry authentication --dry-run=false: If true, only print the object that would be sent, without sending it. --from-file=[]: Key files can be specified using their file path, in which case a default name will be given to them, or optionally with a name and file path, in which case the given name will be used. Specifying a directory will iterate each named file in the directory that is a valid secret key. --generator=‘secret-for-docker-registry/v1‘: The name of the API generator to use. -o, --output=‘‘: Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file. --save-config=false: If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future. --template=‘‘: Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. --validate=true: If true, use a schema to validate the input before sending it
Usage: kubectl create secret docker-registry NAME --docker-username=user --docker-password=password --docker-email=email [--docker-server=string] [--from-literal=key1=value1] [--dry-run] [options]
Use "kubectl options" for a list of global command-line options (applies to all commands).
required flag(s) "docker-password" not set[[email protected] ~]# kubectl create secret docker-registry regsecret --docker-server=10.136.195.150:80 --docker-username=admin -- docker-possword Harbor12345Error: required flag(s) "docker-password" not set
[[email protected] ~]# kubectl create secret docker-registry regsecret \> --docker-server=10.136.195.150:80 \> --docker-username=admin \> --docker-password=Harbor12345 \> ^C[[email protected] ~]# kubectl create secret docker-registry regsecret --docker-server=10.136.195.150:80 --docker-username=admin --docker-password=Harbor12345Error from server (AlreadyExists): secrets "regsecret" already exists[[email protected] ~]# kubectl create secret docker-registry myregsecret --docker-server=10.136.195.150:80 --docker-username=admin --docker-password=Harbor12345secret/myregsecret created[[email protected] ~]# kubectl get secretsNAME TYPE DATA AGEdefault-token-77vdj kubernetes.io/service-account-token 3 41hmyregsecret kubernetes.io/dockerconfigjson 1 18sregsecret kubernetes.io/dockerconfigjson 1 4m7s[[email protected] ~]# lsanaconda-ks.cfg kube-flannel.yml nginx-deployment.yml nginx-service.yml ssm-deployment.yml ssm-service.yml[[email protected] ~]# vi ssm-deployment.yml [[email protected] ~]# kubectl get deployNAME READY UP-TO-DATE AVAILABLE AGEkubernetes-bootcamp 1/1 1 1 26hnginx-deployment 2/2 2 2 26hssm-deployment 0/2 2 0 15m[[email protected] ~]# kubectl delete deploy ssm-deploymentdeployment.extensions "ssm-deployment" deleted[[email protected] ~]# kubectl apply -f ssm-deployment.yml deployment.apps/ssm-deployment created[[email protected] ~]# kubectl get deployNAME READY UP-TO-DATE AVAILABLE AGEkubernetes-bootcamp 1/1 1 1 26h
原文地址:https://www.cnblogs.com/gaohq/p/11856183.html