Google Kubernetes Engine(GKE)にデプロイできない
GKEにRailsをdeployしてみる
を参考に今rubyonrails行っているのですが
myrails_deployment.yaml:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: myrails
spec:
replicas: 1
template:
metadata:
labels:
app: myrails
spec:
containers:
- name: myrails
image: makotooishi/myrails:latest
ports:
- containerPort: 3000
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
#secretを参照
secretKeyRef:
name: myrails-secret
key: db_password
- name: DB_HOST_NAME
value: bold-monkey-mariadb
command: ["bundle", "exec", "rails", "server", "-p", "3000", "-b", "0.0.0.0"]
のところでエラーがでます。
error: error parsing myrails_deployment.yaml: error converting YAML to JSON: yaml: line 23: did not find expected key
create secret generic myrails-secret --from-literal=db_password=password
で再度作り直し
kubectl get secrets myrails-secret -o yaml
apiVersion: v1
data:
db_password: cGFzc3dvcmQ=
kind: Secret
metadata:
creationTimestamp: "2019-01-31T09:15:28Z"
name: myrails-secret
namespace: default
resourceVersion: "1199"
selfLink: /api/v1/namespaces/default/secrets/myrails-secret
uid: c03d81cf-2538-11e9-b191-42010a920003
type: Opaque
のように作成できました。
その後myrails_deployment.yaml:
を行ったんですが次に下記のエラーがでましたので、
error: error validating "myrails_deployment.yaml": error validating data: [ValidationError(Deployment.spec): unknown field "command" in io.k8s.api.extensions.v1beta1.DeploymentSpec, ValidationError(Deployment.spec.template.spec.containers[0].env[0]): unknown field "key" in io.k8s.api.core.v1.EnvVar]; if you choose to ignore these errors, turn validation off with --validate=false
myrails_deployment.yaml:
を下記のように書き換えました
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: myrails
spec:
replicas: 1
template:
metadata:
labels:
app: myrails
spec:
containers:
- name: myrails
image: makotooishi/myrails:latest
ports:
- containerPort: 3000
command: ["bundle", "exec", "rails", "s", "-p", "3000", "-b", "0.0.0.0"]
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: myrails-secret
key: db_password
で次に下記エラーがでました
error: error parsing myrails_deployment.yaml: error converting YAML to JSON: yaml: line 16: did not find expected key
何とか動かしたいのですが、誰か教えてください。お願いします