【发布时间】:2026-01-08 01:45:02
【问题描述】:
在使用 Google Cloud Container 时,我是 Kubernetes 的新手。我只是按照以下教程进行操作:
https://cloud.google.com/container-engine/docs/tutorials/http-balancer http://kubernetes.io/docs/hellonode/#create-your-pod
在这些教程中,我会在运行“kubectl run”后获取副本控制器,但没有副本控制器,因此我无法运行“kubectl expose rc”命令打开端口。
这是我的命令结果:
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
这是我运行“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
我的解决方案之一是创建定义副本控制器的 yaml 文件。但是有没有办法像上面的教程一样通过 kubectl run 命令创建副本控制器?
谢谢,
【问题讨论】:
标签: docker google-cloud-platform kubernetes