我使用 kubernetes 掌舵 Wordpress 安装,我使用 Argo CD 管理一切。如何将 sidecar 容器添加到此部署?
我已经安装了 Wordpress,现在我需要将 wp-content 与 git 存储库同步,因为它是更新文件的唯一方法(bitnami wordpress 是非 root 容器,我无法创建 sftp)。
apiVersion: apps/v1
kind: ReplicaSet
metadata:
annotations:`enter code here`
deployment.kubernetes.io/desired-replicas: '1'
deployment.kubernetes.io/max-replicas: '2'
deployment.kubernetes.io/revision: '2'
creationTimestamp: '2021-08-03T07:52:20Z'
generation: 1
labels:
app.kubernetes.io/instance: projectname
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: wordpress
helm.sh/chart: wordpress-11.1.0
pod-template-hash: 6f744b7944
managedFields:
- apiVersion: apps/v1
fieldsType: FieldsV1
fieldsV1:
'f:metadata':
'f:annotations':
.: {}
'f:deployment.kubernetes.io/desired-replicas': {}
'f:deployment.kubernetes.io/max-replicas': {}
'f:deployment.kubernetes.io/revision': {}
'f:labels':
.: {}
'f:app.kubernetes.io/instance': {}
'f:app.kubernetes.io/managed-by': {}
'f:app.kubernetes.io/name': {}
'f:helm.sh/chart': {}
'f:pod-template-hash': {}
'f:ownerReferences':
.: {}
'k:{"uid":"f1d0a1c2-6564-461e-8be4-2a80784c9d94"}':
.: {}
'f:apiVersion': {}
'f:blockOwnerDeletion': {}
'f:controller': {}
'f:kind': {}
'f:name': {}
'f:uid': {}
'f:spec':
'f:replicas': {}
'f:selector': {}
'f:template':
'f:metadata':
'f:labels':
.: {}
'f:app.kubernetes.io/instance': {}
'f:app.kubernetes.io/managed-by': {}
'f:app.kubernetes.io/name': {}
'f:helm.sh/chart': {}
'f:pod-template-hash': {}
'f:spec':
'f:affinity':
.: {}
'f:podAntiAffinity':
.: {}
'f:preferredDuringSchedulingIgnoredDuringExecution': {}
'f:containers':
'k:{"name":"wordpress"}':
.: {}
'f:env':
.: {}
'k:{"name":"ALLOW_EMPTY_PASSWORD"}':
.: {}
'f:name': {}
'f:value': {}
'k:{"name":"MARIADB_HOST"}':
.: {}
'f:name': {}
'f:value': {}
'k:{"name":"MARIADB_PORT_NUMBER"}':
.: {}
'f:name': {}
'f:value': {}
'k:{"name":"WORDPRESS_AUTO_UPDATE_LEVEL"}':
.: {}
'f:name': {}
'f:value': {}
'k:{"name":"WORDPRESS_BLOG_NAME"}':
.: {}
'f:name': {}
'f:value': {}
'k:{"name":"WORDPRESS_DATABASE_NAME"}':
.: {}
'f:name': {}
'f:value': {}
'k:{"name":"WORDPRESS_DATABASE_PASSWORD"}':
.: {}
'f:name': {}
'f:valueFrom':
.: {}
'f:secretKeyRef':
.: {}
'f:key': {}
'f:name': {}
'k:{"name":"WORDPRESS_DATABASE_USER"}':
.: {}
'f:name': {}
'f:value': {}
'k:{"name":"WORDPRESS_EMAIL"}':
.: {}
'f:name': {}
'f:value': {}
'k:{"name":"WORDPRESS_ENABLE_HTACCESS_PERSISTENCE"}':
.: {}
'f:name': {}
'f:value': {}
'k:{"name":"WORDPRESS_EXTRA_WP_CONFIG_CONTENT"}':
.: {}
'f:name': {}
'k:{"name":"WORDPRESS_FIRST_NAME"}':
.: {}
'f:name': {}
'f:value': {}
'k:{"name":"WORDPRESS_HTACCESS_OVERRIDE_NONE"}':
.: {}
'f:name': {}
'f:value': {}
'k:{"name":"WORDPRESS_LAST_NAME"}':
.: {}
'f:name': {}
'f:value': {}
'k:{"name":"WORDPRESS_PASSWORD"}':
.: {}
'f:name': {}
'f:valueFrom':
.: {}
'f:secretKeyRef':
.: {}
'f:key': {}
'f:name': {}
'k:{"name":"WORDPRESS_PLUGINS"}':
.: {}
'f:name': {}
'f:value': {}
'k:{"name":"WORDPRESS_SCHEME"}':
.: {}
'f:name': {}
'f:value': {}
'k:{"name":"WORDPRESS_SKIP_BOOTSTRAP"}':
.: {}
'f:name': {}
'f:value': {}
'k:{"name":"WORDPRESS_TABLE_PREFIX"}':
.: {}
'f:name': {}
'f:value': {}
'k:{"name":"WORDPRESS_USERNAME"}':
.: {}
'f:name': {}
'f:value': {}
'f:image': {}
'f:imagePullPolicy': {}
'f:livenessProbe':
.: {}
'f:failureThreshold': {}
'f:httpGet':
.: {}
'f:path': {}
'f:port': {}
'f:scheme': {}
'f:initialDelaySeconds': {}
'f:periodSeconds': {}
'f:successThreshold': {}
'f:timeoutSeconds': {}
'f:name': {}
'f:ports':
.: {}
'k:{"containerPort":8080,"protocol":"TCP"}':
.: {}
'f:containerPort': {}
'f:name': {}
'f:protocol': {}
'k:{"containerPort":8443,"protocol":"TCP"}':
.: {}
'f:containerPort': {}
'f:name': {}
'f:protocol': {}
'f:readinessProbe':
.: {}
'f:failureThreshold': {}
'f:httpGet':
.: {}
'f:path': {}
'f:port': {}
'f:scheme': {}
'f:initialDelaySeconds': {}
'f:periodSeconds': {}
'f:successThreshold': {}
'f:timeoutSeconds': {}
'f:resources':
.: {}
'f:requests':
.: {}
'f:cpu': {}
'f:memory': {}
'f:securityContext':
.: {}
'f:runAsNonRoot': {}
'f:runAsUser': {}
'f:terminationMessagePath': {}
'f:terminationMessagePolicy': {}
'f:volumeMounts':
.: {}
'k:{"mountPath":"/bitnami/wordpress"}':
.: {}
'f:mountPath': {}
'f:name': {}
'f:subPath': {}
'f:dnsPolicy': {}
'f:hostAliases':
.: {}
'k:{"ip":"127.0.0.1"}':
.: {}
'f:hostnames': {}
'f:ip': {}
'f:restartPolicy': {}
'f:schedulerName': {}
'f:securityContext':
.: {}
'f:fsGroup': {}
'f:serviceAccount': {}
'f:serviceAccountName': {}
'f:terminationGracePeriodSeconds': {}
'f:volumes':
.: {}
'k:{"name":"wordpress-data"}':
.: {}
'f:name': {}
'f:persistentVolumeClaim':
.: {}
'f:claimName': {}
'f:status':
'f:availableReplicas': {}
'f:fullyLabeledReplicas': {}
'f:observedGeneration': {}
'f:readyReplicas': {}
'f:replicas': {}
manager: kube-controller-manager
operation: Update
time: '2021-08-03T08:13:55Z'
name: projectname-wordpress-6f744b7944
namespace: projectname
ownerReferences:
- apiVersion: apps/v1
blockOwnerDeletion: true
controller: true
kind: Deployment
name: projectname-wordpress
uid: f1d0a1c2-6564-461e-8be4-2a80784c9d94
resourceVersion: '4592350732'
uid: 38b63e07-3845-4057-9476-62229f84621e
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: projectname
app.kubernetes.io/name: wordpress
pod-template-hash: 6f744b7944
template:
metadata:
creationTimestamp: null
labels:
app.kubernetes.io/instance: projectname
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: wordpress
helm.sh/chart: wordpress-11.1.0
pod-template-hash: 6f744b7944
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchLabels:
app.kubernetes.io/instance: projectname
app.kubernetes.io/name: wordpress
namespaces:
- projectname
topologyKey: kubernetes.io/hostname
weight: 1
containers:
- env:
- name: ALLOW_EMPTY_PASSWORD
value: 'yes'
- name: MARIADB_HOST
value: projectname-mariadb
- name: MARIADB_PORT_NUMBER
value: '3306'
- name: WORDPRESS_DATABASE_NAME
value: bitnami_wordpress
- name: WORDPRESS_DATABASE_USER
value: bn_wordpress
- name: WORDPRESS_DATABASE_PASSWORD
valueFrom:
secretKeyRef:
key: mariadb-password
name: projectname-mariadb
- name: WORDPRESS_USERNAME
value: user
- name: WORDPRESS_PASSWORD
valueFrom:
secretKeyRef:
key: wordpress-password
name: projectname-wordpress
- name: WORDPRESS_EMAIL
value: user@example.com
- name: WORDPRESS_FIRST_NAME
value: FirstName
- name: WORDPRESS_LAST_NAME
value: LastName
- name: WORDPRESS_HTACCESS_OVERRIDE_NONE
value: 'no'
- name: WORDPRESS_ENABLE_HTACCESS_PERSISTENCE
value: 'no'
- name: WORDPRESS_BLOG_NAME
value: User's Blog!
- name: WORDPRESS_SKIP_BOOTSTRAP
value: 'no'
- name: WORDPRESS_TABLE_PREFIX
value: wp_
- name: WORDPRESS_SCHEME
value: http
- name: WORDPRESS_EXTRA_WP_CONFIG_CONTENT
- name: WORDPRESS_AUTO_UPDATE_LEVEL
value: none
- name: WORDPRESS_PLUGINS
value: none
image: 'docker.io/bitnami/wordpress:5.7.2-debian-10-r29'
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 6
httpGet:
path: /wp-admin/install.php
port: http
scheme: HTTP
initialDelaySeconds: 120
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
name: wordpress
ports:
- containerPort: 8080
name: http
protocol: TCP
- containerPort: 8443
name: https
protocol: TCP
readinessProbe:
failureThreshold: 6
httpGet:
path: /wp-login.php
port: http
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
resources:
requests:
cpu: 300m
memory: 512Mi
securityContext:
runAsNonRoot: true
runAsUser: 1001
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /bitnami/wordpress
name: wordpress-data
subPath: wordpress
dnsPolicy: ClusterFirst
hostAliases:
- hostnames:
- status.localhost
ip: 127.0.0.1
restartPolicy: Always
schedulerName: default-scheduler
securityContext:
fsGroup: 1001
serviceAccount: default
serviceAccountName: default
terminationGracePeriodSeconds: 30
volumes:
- name: wordpress-data
persistentVolumeClaim:
claimName: projectname-wordpress
status:
availableReplicas: 1
fullyLabeledReplicas: 1
observedGeneration: 1
readyReplicas: 1
replicas: 1
有人建议添加这个:
sidecars:
- name: git-sync
image: bitnami/git:2.32.0-debian-10-r24
imagePullPolicy: IfNotPresent
command:
- /bin/bash
- -ec
- |
[[ -f "/opt/bitnami/scripts/git/entrypoint.sh" ]] && source "/opt/bitnami/scripts/git/entrypoint.sh"
while true; do
#Add here your commands to synchronize the git repository with /bitnami/wordpress/wp-content
sleep 60
done
volumeMounts:
- mountPath: /bitnami/wordpress
name: wordpress-data
subPath: Wordpress
但我正在努力,但我不确定我做得很好。