繁体   English   中英

Kubernetes 使用 yaml 文件创建副本集失败

[英]Kubernetes replicaset creation using yaml file failed

运行命令时: kubectl create -f rs.yaml报错

rs.yaml

kind: ReplicaSet
apiVersion: apps/v1
metadata:
  name: myrs
spec:
  replicas: 3
  selector:
    matchLabels:
      app: rsexample
  template:
    metadata:
      labels:
        app: rsexample
    spec:
      containers:
      - name: rscontainer
        image: aamirpinger/helloworld:latest
        ports:
        - containerPort: 80

运行命令时: kubectl create -f rs.yaml报错

error: error parsing rs.yaml: error converting YAML to JSON: yaml: line 13: found character that cannot start any token

它的缩进问题,使用制表符代替空格(在行中用空格替换制表符时:13 错误解决)

yaml 中的缩进错误。 这是一个有效的示例。 由于您上传的是图像而不是实际的 yaml,因此无法在答案中修复您的 yaml。

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: frontend
  labels:
    app: guestbook
    tier: frontend
spec:
  # modify replicas according to your case
  replicas: 3
  selector:
    matchLabels:
      tier: frontend
  template:
    metadata:
      labels:
        tier: frontend #Look here
    spec:
      containers:
      - name: php-redis
        image: gcr.io/google_samples/gb-frontend:v3

暂无
暂无

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

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