[英]AKS - How to mount volume with file for pod/image
I am kind of new to AKS deployment with volume mount.我对使用卷挂载的 AKS 部署有点陌生。 I want to create a pod in AKS with image;我想在 AKS 中创建一个带有图像的 pod; that image needs a volume mount with config.yaml file (that I already have and needs to be passed to that image to run successfully).该映像需要使用 config.yaml 文件进行卷挂载(我已经拥有并且需要将其传递给该映像才能成功运行)。
Below is the docker command that is working on local machine.下面是在本地机器上运行的 docker 命令。
docker run -v <Absolute_path_of_config.yaml>:/config.yaml image:tag
I want to achieve same thing in AKS.我想在 AKS 中实现同样的目标。 When I tried to deploy same using Azure File Mount (with PersistentVolumeClaim) volume is getting attached.当我尝试使用 Azure 文件挂载(使用 PersistentVolumeClaim)进行部署时,卷已附加。 The question now is how to pass config.yaml file to that pod.现在的问题是如何将 config.yaml 文件传递给该 pod。 I tried uploading config.yaml file to Azure File Share Volume that is attached in POD deployment without any success.我尝试将 config.yaml 文件上传到 POD 部署中附加的 Azure 文件共享卷,但没有成功。
Below is the pod deployment file that I used下面是我使用的 pod 部署文件
kind: Pod
apiVersion: v1
metadata:
name: mypod
spec:
containers:
- name: mypod
image: image:tag
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 250m
memory: 1Gi
volumeMounts:
- mountPath: "/config.yaml"
name: volume
volumes:
- name: volume
persistentVolumeClaim:
claimName: my-azurefile-storage
Need help regarding how I can use that local config.yaml file for aks deployment so image can run properly.需要有关如何使用本地 config.yaml 文件进行 aks 部署的帮助,以便映像可以正常运行。
Thanks in advance.提前致谢。
Create a kubernetes secret using config.yaml
file.使用config.yaml
文件创建 kubernetes 机密。
kubectl create secret generic config-yaml --from-file=config.yaml
Mount it as a volume in the pod.将其作为卷安装在 pod 中。
apiVersion: v1
kind: Pod
metadata:
name: config
spec:
containers:
- name: config
image: alpine
command:
- cat
resources: {}
tty: true
volumeMounts:
- name: config
mountPath: /config.yaml
subPath: config.yaml
volumes:
- name: config
secret:
secretName: config-yaml
Exec to the pod and view the file.执行到 pod 并查看文件。
kubectl exec -it config sh
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
/ # ls
bin dev home media opt root sbin sys usr
config.yaml etc lib mnt proc run srv tmp var
/ # cat config.yaml
---
apiUrl: "https://my.api.com/api/v1"
username: admin
password: password
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.