argocd-production
argocd-production copied to clipboard
patch new new PVC to exiting pod
Hi,
Can we patch new PVC to existing deployment or we can patch changes to exiting services only?
I'm not sure I understood the question. Are you referring to one of the Gists that accompany this repo?
If you can provide a bit more info I'll do my best to resolve it.
I have deployed 1 PVC with a WordPress pod. Now I want to add another PVC without touching the main manifest files.
Now my question is can I do this with Kustomize.yaml?
Kustomize normally organizes manifests by using base
directory and then overlays/ENV
dir for each environment. If, for example, you'd like to add a PVC into production, you would add it to overlays/production
dir and leave base
intact. Is that what you meant?
Yes, I meant the same and doing same as you mentioned.
This is my WordPress.YAML file in base.
apiVersion: v1
kind: Service
metadata:
name: wordpress
labels:
app: wordpress
spec:
ports:
- port: 80
selector:
app: wordpress
tier: frontend
type: LoadBalancer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: wp-pv-claim
labels:
app: wordpress1
spec:
storageClassName: px-file-sc
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 200Mi
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: wordpress
labels:
app: wordpress
spec:
selector:
matchLabels:
app: wordpress
tier: frontend
strategy:
type: Recreate
template:
metadata:
labels:
app: wordpress
tier: frontend
spec:
containers:
- image: nishit2408/argo-imageupdater
name: wordpress
env:
- name: WORDPRESS_DB_HOST
value: wordpress-mysql
- name: WORDPRESS_DB_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-pass # generated before in secret.yml
key: password
ports:
- containerPort: 80
name: wordpress
volumeMounts:
- name: wordpress-persistent-storage
mountPath: "/var/www/html/wordpress" # which data will be stored
volumes:
- name: wordpress-persistent-storage
persistentVolumeClaim:
claimName: wp-pv-claim
And this is my manifest file to add new PVC inside overlays/production dir
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: wp-pv-claim2
labels:
app: wordpress1
spec:
storageClassName: px-file-sc
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 200Mi
It gives me error when apply manifest file using -K
error: no matches for Id ~G_v1_PersistentVolumeClaim|~X|wp-pv-claim2; failed to find unique target for patch ~G_v1_PersistentVolumeClaim|wp-pv-claim2
Can you paste your kustomize.yaml files (from both dirs)?
Here is kustomize.yaml from base dir
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- wordpress.yaml
Here is kustomize.yaml from overlays/production dir
bases:
- ../../base
patches:
- path: add-pvc.yaml
Assuming that add-pvc.yaml contains the definition of wp-pv-claim2
, the problem is that you are trying to patch a resource that does not exist. If you're trying to add a new PVC instead of modifying an existing one, you would add add-pvc.yaml
into resources
section of kustomize.yaml inside the overlays/production
directory.
Thanks, now I got what I was doing wrong.
Hi,
I am trying to add multiple pod specs using Kustomize. However, it is adding the last one. I am using patchesStrategicMerge:
for this. Below are spec I am trying to add
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: maven-app1
namespace: argocd
spec:
generators:
- list:
elements:
- cluster: rancher
url: https://192.168.29.143:6443/
---
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: maven-app1
namespace: argocd
spec:
generators:
- list:
elements:
- cluster: baremetal
url: https://192.168.29.145:6443/
Both of those are having the same name
and are in the same namespace
so one is overwriting the other.
Ok but that I am giving to identify the target which is in base
. If I give a different name or namespace then it is unable to find the target.
I'm not sure what you're trying to do. If you want maven-app1
to run in both rancher
and baremetal
clusters, than you should have two entries in the spec.generators.list
entry.
Personally, I am not using ApplicationSet
. It's only a workaround that creates Argp CD Application
resources. I think it's a wrong direction for Argo CD. It Argo CD would like to be massive multi-cluster solution, it should copy what Rancher Fleet did. But, for anything below "massive", is quite OK with Application
(without ApplicationSet
).
I am trying to add multiple entries in the spec.generators.list
using Kustomize. Above those are entries. when I do kustomize build, then it only adds the last one entry only. though it should add both entries.
I do not think you posted the kustomize.yaml file. There's the one from January 3 but I'm guessing that's not the one used with the ApplicationSet
.