kubernetes使用不同的命令创建多个相同图像的豆荚/部署
我在单个豆荚内部部署了2个容器(container-test2和cloudsql-proxy)。kubernetes使用不同的命令创建多个相同图像的豆荚/部署
container-test2运行一个docker映像,它将[“my_app”,“arg1”,“arg2”]作为CMD传递。我想用不同的参数组合运行这个容器的几个实例。我也想在单独的窗格中运行它们,以便我可以在节点上分发它们。我不完全确定如何做到这一点。
我可以成功运行这两个容器,但我不知道如何使用不同参数进行container-test2复制,并使每个容器都在单独的容器中启动。
apiVersion: extensions/v1beta1 kind: Deployment
metadata:
name: test
spec:
replicas: 1
template:
metadata:
labels:
app: test
spec:
containers:
- image: gcr.io/testing-11111/testology:latest
name: container-test2
command: ["my_app", "arg1", "arg2"]
env:
- name: DB_HOST
# Connect to the SQL proxy over the local network on a fixed port.
# Change the [PORT] to the port number used by your database
# (e.g. 3306).
value: 127.0.0.1:5432
# These secrets are required to start the pod.
# [START cloudsql_secrets]
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: cloudsql-db-credentials
key: password
- name: DB_USER
valueFrom:
secretKeyRef:
name: cloudsql-db-credentials
key: username
# [END cloudsql_secrets]
resources:
requests:
#memory: "64Mi"
cpu: 0.1
limits:
memory: "375Mi"
cpu: 0.15
# Change [INSTANCE_CONNECTION_NAME] here to include your GCP
# project, the region of your Cloud SQL instance and the name
# of your Cloud SQL instance. The format is
# $PROJECT:$REGION:$INSTANCE
# Insert the port number used by your database.
# [START proxy_container]
- image: gcr.io/cloudsql-docker/gce-proxy:1.09
name: cloudsql-proxy
command: ["/cloud_sql_proxy", "--dir=/cloudsql",
"-instances=testing-11111:europe-west2:testology=tcp:5432",
"-credential_file=/secrets/cloudsql/credentials.json"]
volumeMounts:
- name: cloudsql-instance-credentials
mountPath: /secrets/cloudsql
readOnly: true
- name: ssl-certs
mountPath: /etc/ssl/certs
- name: cloudsql
mountPath: /cloudsql
# [END proxy_container]
resources:
requests:
#memory: "64Mi"
cpu: 0.1
limits:
memory: "375Mi"
cpu: 0.15
# [START volumes]
volumes:
- name: cloudsql-instance-credentials
secret:
secretName: cloudsql-instance-credentials
- name: ssl-certs
hostPath:
path: /etc/ssl/certs
- name: cloudsql
emptyDir:
# [END volumes]
编辑:解
我解决它通过创建部署配置的多个拷贝到目录“部署”,修改名称和命令,然后运行:
kubectl创建-f部署/
回答:
你不能让individua l副本运行不同的参数,它们不会像“精确副本”那样是副本。如果你想用不同的参数多次运行你的应用程序,你需要使用多个部署。
复制的容器在其自己的Pod中运行,例如,应该有三个豆荚存在的部署扩展到三个重复
以上是 kubernetes使用不同的命令创建多个相同图像的豆荚/部署 的全部内容, 来源链接: utcz.com/qa/258667.html