使用 Kompose 将 docker-compose 转换为 kubernetes
Converting docker-compose to kubernetes using Kompose
我是 Kubernetes 的新手,我看到有一种方法可以运行 Kompose,但我收到了这个错误:
root@master-node:kompose --file docker-compose.yml --volumes hostPath up
INFO We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.
FATA Error while deploying application: Error loading config file "/etc/kubernetes/admin.conf": open /etc/kubernetes/admin.conf: permission denied
ls -l /etc/kubernetes/admin.conf
-rw------- 1 root root 5593 Jun 14 08:59 /etc/kubernetes/admin.conf
我怎样才能使这个工作?
系统信息:
Ubuntu18
客户端版本:version.Info:主要:“1”,次要:“21”
我也试过让它像那样工作:
kompose convert --volumes hostPath
INFO Kubernetes file "postgres-1-service.yaml" created
INFO Kubernetes file "postgres-2-service.yaml" created
INFO Kubernetes file "postgres-1-deployment.yaml" created
INFO Kubernetes file "postgres-2-deployment.yaml" created
kubectl create -f postgres-1-service.yaml,postgres-2-service.yaml,postgres-1-deployment.yaml,postgres-1-claim0-persistentvolumeclaim.yaml,postgres-1-claim1-persistentvolumeclaim.yaml,postgres-2-deployment.yaml,postgres-2-claim0-persistentvolumeclaim.yaml
我只在 postgres-1-deployment.yaml 和 postgres-2-deployment.yaml.
上遇到这个错误
service/postgres-1 created
service/postgres-2 created
persistentvolumeclaim/postgres-1-claim0 created
persistentvolumeclaim/postgres-1-claim1 created
persistentvolumeclaim/postgres-2-claim0 created
Error from server (BadRequest): error when creating "postgres-1-deployment.yaml": Deployment in version "v1" cannot be handled as a Deployment: v1.Deployment.Spec: v1.DeploymentSpec.Template: v1.PodTemplateSpec.Spec: v1.PodSpec.Containers: []v1.Container: v1.Container.Env: []v1.EnvVar: v1.EnvVar.Value: ReadString: expects " or n, but found t, error found in #10 byte of ...|,"value":true},{"nam|..., bigger context ...|sword"},{"name":"REPMGR_PGHBA_TRUST_ALL","value":true},{"name":"REPMGR_PRIMARY_HOST","value":"postgr|...
Error from server (BadRequest): error when creating "postgres-2-deployment.yaml": Deployment in version "v1" cannot be handled as a Deployment: v1.Deployment.Spec: v1.DeploymentSpec.Template: v1.PodTemplateSpec.Spec: v1.PodSpec.Containers: []v1.Container: v1.Container.Env: []v1.EnvVar: v1.EnvVar.Value: ReadString: expects " or n, but found t, error found in #10 byte of ...|,"value":true},{"nam|..., bigger context ...|sword"},{"name":"REPMGR_PGHBA_TRUST_ALL","value":true},{"name":"REPMGR_PRIMARY_HOST","value":"postgr|...
postgres-1-deployment.yaml 示例:
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: /snap/kompose/19/kompose-linux-amd64 convert --volumes hostPath
kompose.version: 1.21.0 (992df58d8)
creationTimestamp: null
labels:
io.kompose.service: postgres-1
name: postgres-1
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: postgres-1
strategy:
type: Recreate
template:
metadata:
annotations:
kompose.cmd: /snap/kompose/19/kompose-linux-amd64 convert --volumes hostPath
kompose.version: 1.21.0 (992df58d8)
creationTimestamp: null
labels:
io.kompose.service: postgres-1
spec:
containers:
- env:
- name: BITNAMI_DEBUG
value: "true"
- name: POSTGRESQL_PASSWORD
value: password
- name: POSTGRESQL_POSTGRES_PASSWORD
value: adminpassword
- name: POSTGRESQL_USERNAME
value: user
- name: REPMGR_NODE_NAME
value: postgres-1
- name: REPMGR_NODE_NETWORK_NAME
value: postgres-1
- name: REPMGR_PARTNER_NODES
value: postgres-1,postgres-2:5432
- name: REPMGR_PASSWORD
value: repmgrpassword
- name: REPMGR_PGHBA_TRUST_ALL
value: yes
- name: REPMGR_PRIMARY_HOST
value: postgres-1
- name: REPMGR_PRIMARY_PORT
value: "5432"
image: bitnami/postgresql-repmgr:11
imagePullPolicy: ""
name: postgres-1
ports:
- containerPort: 5432
resources: {}
volumeMounts:
- mountPath: /bitnami/postgresql
name: postgres-1-hostpath0
- mountPath: /docker-entrypoint-initdb.d
name: postgres-1-hostpath1
restartPolicy: Always
serviceAccountName: ""
volumes:
- hostPath:
path: /db4_data
name: postgres-1-hostpath0
- hostPath:
path: /root/ansible/api/posrgres11/cluster
name: postgres-1-hostpath1
status: {}
kompose 翻译 deploy.yml 文件的方式有误吗?我做了一切,比如在 kompose guid
上的指导
认为问题是 Kompose 翻译的 env 值 true 没有引号 "true"
使用了这个验证器 https://kubeyaml.com/
我是 Kubernetes 的新手,我看到有一种方法可以运行 Kompose,但我收到了这个错误:
root@master-node:kompose --file docker-compose.yml --volumes hostPath up
INFO We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.
FATA Error while deploying application: Error loading config file "/etc/kubernetes/admin.conf": open /etc/kubernetes/admin.conf: permission denied
ls -l /etc/kubernetes/admin.conf
-rw------- 1 root root 5593 Jun 14 08:59 /etc/kubernetes/admin.conf
我怎样才能使这个工作?
系统信息: Ubuntu18 客户端版本:version.Info:主要:“1”,次要:“21”
我也试过让它像那样工作:
kompose convert --volumes hostPath
INFO Kubernetes file "postgres-1-service.yaml" created
INFO Kubernetes file "postgres-2-service.yaml" created
INFO Kubernetes file "postgres-1-deployment.yaml" created
INFO Kubernetes file "postgres-2-deployment.yaml" created
kubectl create -f postgres-1-service.yaml,postgres-2-service.yaml,postgres-1-deployment.yaml,postgres-1-claim0-persistentvolumeclaim.yaml,postgres-1-claim1-persistentvolumeclaim.yaml,postgres-2-deployment.yaml,postgres-2-claim0-persistentvolumeclaim.yaml
我只在 postgres-1-deployment.yaml 和 postgres-2-deployment.yaml.
上遇到这个错误service/postgres-1 created
service/postgres-2 created
persistentvolumeclaim/postgres-1-claim0 created
persistentvolumeclaim/postgres-1-claim1 created
persistentvolumeclaim/postgres-2-claim0 created
Error from server (BadRequest): error when creating "postgres-1-deployment.yaml": Deployment in version "v1" cannot be handled as a Deployment: v1.Deployment.Spec: v1.DeploymentSpec.Template: v1.PodTemplateSpec.Spec: v1.PodSpec.Containers: []v1.Container: v1.Container.Env: []v1.EnvVar: v1.EnvVar.Value: ReadString: expects " or n, but found t, error found in #10 byte of ...|,"value":true},{"nam|..., bigger context ...|sword"},{"name":"REPMGR_PGHBA_TRUST_ALL","value":true},{"name":"REPMGR_PRIMARY_HOST","value":"postgr|...
Error from server (BadRequest): error when creating "postgres-2-deployment.yaml": Deployment in version "v1" cannot be handled as a Deployment: v1.Deployment.Spec: v1.DeploymentSpec.Template: v1.PodTemplateSpec.Spec: v1.PodSpec.Containers: []v1.Container: v1.Container.Env: []v1.EnvVar: v1.EnvVar.Value: ReadString: expects " or n, but found t, error found in #10 byte of ...|,"value":true},{"nam|..., bigger context ...|sword"},{"name":"REPMGR_PGHBA_TRUST_ALL","value":true},{"name":"REPMGR_PRIMARY_HOST","value":"postgr|...
postgres-1-deployment.yaml 示例:
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: /snap/kompose/19/kompose-linux-amd64 convert --volumes hostPath
kompose.version: 1.21.0 (992df58d8)
creationTimestamp: null
labels:
io.kompose.service: postgres-1
name: postgres-1
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: postgres-1
strategy:
type: Recreate
template:
metadata:
annotations:
kompose.cmd: /snap/kompose/19/kompose-linux-amd64 convert --volumes hostPath
kompose.version: 1.21.0 (992df58d8)
creationTimestamp: null
labels:
io.kompose.service: postgres-1
spec:
containers:
- env:
- name: BITNAMI_DEBUG
value: "true"
- name: POSTGRESQL_PASSWORD
value: password
- name: POSTGRESQL_POSTGRES_PASSWORD
value: adminpassword
- name: POSTGRESQL_USERNAME
value: user
- name: REPMGR_NODE_NAME
value: postgres-1
- name: REPMGR_NODE_NETWORK_NAME
value: postgres-1
- name: REPMGR_PARTNER_NODES
value: postgres-1,postgres-2:5432
- name: REPMGR_PASSWORD
value: repmgrpassword
- name: REPMGR_PGHBA_TRUST_ALL
value: yes
- name: REPMGR_PRIMARY_HOST
value: postgres-1
- name: REPMGR_PRIMARY_PORT
value: "5432"
image: bitnami/postgresql-repmgr:11
imagePullPolicy: ""
name: postgres-1
ports:
- containerPort: 5432
resources: {}
volumeMounts:
- mountPath: /bitnami/postgresql
name: postgres-1-hostpath0
- mountPath: /docker-entrypoint-initdb.d
name: postgres-1-hostpath1
restartPolicy: Always
serviceAccountName: ""
volumes:
- hostPath:
path: /db4_data
name: postgres-1-hostpath0
- hostPath:
path: /root/ansible/api/posrgres11/cluster
name: postgres-1-hostpath1
status: {}
kompose 翻译 deploy.yml 文件的方式有误吗?我做了一切,比如在 kompose guid
上的指导认为问题是 Kompose 翻译的 env 值 true 没有引号 "true" 使用了这个验证器 https://kubeyaml.com/