Create rc-definition.yml file. be careful of tabs and indents.
# cat rc-definition.yml
apiVersion: v1
kind: ReplicationController
metadata:
name: myapp-rc
labels:
app: myapp
type: front-end
spec:
template:
metadata:
name: myapp-prod
labels:
app: myapp
type: front-end
spec:
containers:
- name: nginx-controller
image: nginx
replicas: 2
# cat rc-definition.yml
apiVersion: v1
kind: ReplicationController
metadata:
name: myapp-rc
labels:
app: myapp
type: front-end
spec:
template:
metadata:
name: myapp-prod
labels:
app: myapp
type: front-end
spec:
containers:
- name: nginx-controller
image: nginx
replicas: 2
Run below command to create the pods
# kubectl create -f rc-definition.yml
replicationcontroller/myapp-rc created
when you run the above commands, errors like the below may come if the indentation is incorrect, or there is a array instead of a map
error: error parsing rc-definition.yml: error converting YAML to JSON: yaml: line 6: found character that cannot start any token
error: error parsing rc-definition.yml: error converting YAML to JSON: yaml: line 16: found a tab character that violates indentation
error: error validating "rc-definition.yml": error validating data: ValidationError(ReplicationController.spec): invalid type for io.k8s.api.core.v1.ReplicationControllerSpec: got "array", expected "map"; if you choose to ignore these errors, turn validation off with --validate=false
# kubectl get replicationcontroller
NAME DESIRED CURRENT READY AGE
myapp-rc 2 2 2 14m
# kubectl get pods
NAME READY STATUS RESTARTS AGE
myapp-rc-69v2d 1/1 Running 0 14m
myapp-rc-fw8z4 1/1 Running 0 14m
mynginx-6b7b7bcd75-l7jwv 1/1 Running 1 25h
nginx-7cdbd8cdc9-g2tcv 1/1 Running 2 9d
NAME DESIRED CURRENT READY AGE
myapp-rc 2 2 2 14m
# kubectl get pods
NAME READY STATUS RESTARTS AGE
myapp-rc-69v2d 1/1 Running 0 14m
myapp-rc-fw8z4 1/1 Running 0 14m
mynginx-6b7b7bcd75-l7jwv 1/1 Running 1 25h
nginx-7cdbd8cdc9-g2tcv 1/1 Running 2 9d
No comments:
Post a Comment