我有一个包含所有kubernetes pods文件夹的存储库,在每个文件夹中我有2个文件,假设我有一个文件夹名称“MyApp”,所以在这个文件夹中我有:
controller.yaml
看起来像这样:(这是我的rc)
apiVersion: v1
kind: ReplicationController
metadata:
name: MyApp
labels:
name: MyApp
spec:
replicas: 1
selector:
name: MyApp
template:
metadata:
labels:
name: MyApp
version: 0.1.4
spec:
containers:
- name: MyApp
#this is the image artifactory
image: docker-docker-release.someartifactory.com/MyApp:0.1.4
ports:
- containerPort: 9000
imagePullSecrets:
- name: myCompany-artifactory
service.yaml
看起来像这样:
apiVersion: v1
kind: Service
metadata:
name: MyApp
labels:
name: MyApp
spec:
# if your cluster supports it, uncomment the following to automatically create
# an external load-balanced IP for the frontend service.
type: LoadBalancer
ports:
# the port that this service should serve on
- port: 9000
selector:
name: MyApp
现在,我运行kubectl get services
列出我的所有服务,然后我得到:
NAME LABELS SELECTOR IP(S) PORT(S)
kubernetes component=apiserver,provider=kubernetes <none> xxxxx
为什么我没有得到我的所有服务?
答案 0 :(得分:1)
您有1个服务,1个 ReplicationController
首先需要同时创建:
kubectl create -f service.yaml
和
kubectl create -f controller.yaml
然后用:
kubectl get services
显示服务
kubectl get rc
显示了ReplicationControllers
kubectl get pods
显示了由ReplicationController部署的Pod。