简体   繁体   English

kubectl run 不创建副本控制器

[英]kubectl run does not create replicacontroller

I'm newbie of the Kubernetes while I'm using Google Cloud Container.我在使用 Google Cloud Container 时是 Kubernetes 的新手。 I just follow the tutorials as belows:我只是按照以下教程进行操作:

https://cloud.google.com/container-engine/docs/tutorials/http-balancer http://kubernetes.io/docs/hellonode/#create-your-pod https://cloud.google.com/container-engine/docs/tutorials/http-balancer http://kubernetes.io/docs/hellonode/#create-your-pod

In these tutorials, I'll get the replicacontroller after I run the "kubectl run" but there is no replicacontrollers so that I cannot run the command of "kubectl expose rc" in order to open a port.在这些教程中,我将在运行“kubectl run”后获取副本控制器,但没有副本控制器,因此我无法运行“kubectl expose rc”命令来打开端口。

Here is my result of the commands:这是我的命令结果:

ChangMatthews-MacBook-Pro:frontend changmatthew$ kubectl run nginx --image=nginx --port=80
deployment "nginx" created

ChangMatthews-MacBook-Pro:frontend changmatthew$ kubectl expose rc nginx --target-port=80 --type=NodePort
Error from server: replicationcontrollers "nginx" not found

Here is my result when I run "kubectl get rc,svc,ingress,deployments,pods":这是我运行“kubectl get rc,svc,ingress,deployments,pods”时的结果:

ChangMatthews-MacBook-Pro:frontend changmatthew$ kubectl get rc,svc,ingress,deployments,pods
NAME                    CLUSTER-IP   EXTERNAL-IP   PORT(S)           AGE
kubernetes              10.3.240.1   <none>        443/TCP           12m
NAME                    RULE         BACKEND       ADDRESS           AGE
basic-ingress           -            nginx:80      107.178.247.247   12m
NAME                    DESIRED      CURRENT       UP-TO-DATE        AVAILABLE   AGE
nginx                   1            1             1                 1           11m
NAME                    READY        STATUS        RESTARTS          AGE
nginx-198147104-zgo7m   1/1          Running       0                 11m

One of my solution is to create yaml file which define the replicacontroller.我的解决方案之一是创建定义副本控制器的 yaml 文件。 But is there any way to create replicacontroller via kubectl run command like above tutorials?但是有没有办法像上面的教程一样通过 kubectl run 命令创建副本控制器?

Thanks,谢谢,

现在,kubectl运行创建了一个部署,您可以指定在部署而不是复制控制器中公开的类型:

kubectl expose deployment nginx --target-port=80 --type=NodePort

The team might still be updating the docs to reflect 1.2. 团队可能仍在更新文档以反映1.2。 Note the output you got: 注意您得到的输出:

$ kubectl run nginx --image=nginx --port=80 $ kubectl运行nginx --image = nginx --port = 80
deployment "nginx" created 部署“ nginx”已创建

kubectl run now creates a deployemtn+replica-set. 现在,kubectl运行会创建一个deployemtn +副本集。 To view these you can do kubectl get deployment, and get rs respectively. 要查看这些,您可以分别执行kubectl获取部署和获取rs。 Deployments are essentially a nicer way to perform rolling update server side, but there's a little more to it. 从本质上讲,部署是执行滚动更新服务器端的一种更好的方法,但还有更多功能。 See docs: http://kubernetes.io/docs/user-guide/deployments/ 参见文档: http : //kubernetes.io/docs/user-guide/deployments/

In version 1.15.0, it works as follows.在 1.15.0 版本中,它的工作原理如下。

root@k8smaster ~]# kubectl run guestbook --image=coolguy/k8s_guestbook:1.0 --port=8080 --generator=run/v1 kubectl run --generator=run/v1 is DEPRECATED and will be removed in a future version. root@k8smaster ~]# kubectl run guestbook --image=coolguy/k8s_guestbook:1.0 --port=8080 --generator=run/v1 kubectl run --generator=run/v1 已弃用,将在未来版本中删除。 Use kubectl run --generator=run-pod/v1 or kubectl create instead.请改用 kubectl run --generator=run-pod/v1 或 kubectl create。 replicationcontroller/guestbook created复制控制器/留言簿已创建

In version 1.19.0在版本 1.19.0

[root@k8smaster ~]# kubectl run guestbook --image=dmsong2008/k8s_guestbook:1.0 --port=8080 --generator=run/v1 Flag --generator has been deprecated, has no effect and will be removed in the future. [root@k8smaster ~]# kubectl run guestbook --image=dmsong2008/k8s_guestbook:1.0 --port=8080 --generator=run/v1标志 --generator 已被弃用,没有任何影响,将来会被移除。 pod/guestbook created pod/留言簿已创建

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM