Is there a way to make kustomize merge headings in a yaml file instead of completely replacing that heading with the overlay yamlKubernetes equivalent of env-file in Dockerrequests.get(url) return error code 404 from kubernetes api while the response could be get via curl/GETKubectl apply for a deployment with revHistoryLimit 0 does not delete the old replica set, here is my deploment templateHow to start a pod in command line without deployment in kubernetes?How to map one single file into kubernetes pod using hostPath?Kubernetes doesn't allow to mount file to containerHow to mount a volume with a windows container in kubernetes?Share nfs volume between kubernetes clustersNot able to see Pod when I create a Jobkubeadm install flannel get error, what's wrong?
Have there ever been other TV shows or Films that told a similiar story to the new 90210 show?
How to render "have ideas above his station" into German
What does a comma signify in inorganic chemistry?
My new Acer Aspire 7 doesn't have a Legacy Boot option, what can I do to get it?
A reccomended structured approach to self studying music theory for songwriting
What is the opposite of "hunger level"?
Why should I pay for an SSL certificate?
Unconventional examples of mathematical modelling
Photoshop older default brushes
Polar contour plot in Mathematica?
Eric Andre had a dream
Would getting a natural 20 with a penalty still count as a critical hit?
If a person claims to know anything could it be disproven by saying 'prove that we are not in a simulation'?
What should I do with the stock I own if I anticipate there will be a recession?
Why don't modern jet engines use forced exhaust mixing?
Has there ever been a truly bilingual country prior to the contemporary period?
Units of measurement, especially length, when body parts vary in size among races
Expressing a chain of boolean ORs using ILP
When does The Truman Show take place?
What is the purpose/function of this power inductor in parallel?
Heyawacky: Ace of Cups
Why is su world executable?
Get the full text of a long request
Are there any OR challenges that are similar to kaggle's competitions?
Is there a way to make kustomize merge headings in a yaml file instead of completely replacing that heading with the overlay yaml
Kubernetes equivalent of env-file in Dockerrequests.get(url) return error code 404 from kubernetes api while the response could be get via curl/GETKubectl apply for a deployment with revHistoryLimit 0 does not delete the old replica set, here is my deploment templateHow to start a pod in command line without deployment in kubernetes?How to map one single file into kubernetes pod using hostPath?Kubernetes doesn't allow to mount file to containerHow to mount a volume with a windows container in kubernetes?Share nfs volume between kubernetes clustersNot able to see Pod when I create a Jobkubeadm install flannel get error, what's wrong?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
i have a base yaml and an overlay yaml and using "kustomize" i want to merge these two yaml. what happens with me is that on running kustomize build there comes an output but it is not expected why? because the kustomize instead of filling the custom information from the overlay yaml replaces the whole heading tag of the base with the overlay "containers" in my case. The intended behaviour that i need is the it should somehow fill in the missing information using the overlay yaml instead of replacement.
base yaml:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- name: temp
image: temp
imagePullPolicy: Always
command: temp
args:
temp
envFrom:
- configMapRef:
name: temp
volumeMounts:
volumes:
overlay yaml:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
volumeMounts:
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
Expected result after kustomize build:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- name: temp
image: temp
imagePullPolicy: Always
command: temp
args:
["sleep 9000"]
envFrom:
- configMapRef:
name: temp
volumeMounts:
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
what i'm getting:
apiVersion: v1
kind: Pod
metadata:
labels:
tier: temp
name: temp
spec:
containers:
volumeMounts:
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
merge kubernetes yaml kustomize
add a comment |
i have a base yaml and an overlay yaml and using "kustomize" i want to merge these two yaml. what happens with me is that on running kustomize build there comes an output but it is not expected why? because the kustomize instead of filling the custom information from the overlay yaml replaces the whole heading tag of the base with the overlay "containers" in my case. The intended behaviour that i need is the it should somehow fill in the missing information using the overlay yaml instead of replacement.
base yaml:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- name: temp
image: temp
imagePullPolicy: Always
command: temp
args:
temp
envFrom:
- configMapRef:
name: temp
volumeMounts:
volumes:
overlay yaml:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
volumeMounts:
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
Expected result after kustomize build:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- name: temp
image: temp
imagePullPolicy: Always
command: temp
args:
["sleep 9000"]
envFrom:
- configMapRef:
name: temp
volumeMounts:
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
what i'm getting:
apiVersion: v1
kind: Pod
metadata:
labels:
tier: temp
name: temp
spec:
containers:
volumeMounts:
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
merge kubernetes yaml kustomize
add a comment |
i have a base yaml and an overlay yaml and using "kustomize" i want to merge these two yaml. what happens with me is that on running kustomize build there comes an output but it is not expected why? because the kustomize instead of filling the custom information from the overlay yaml replaces the whole heading tag of the base with the overlay "containers" in my case. The intended behaviour that i need is the it should somehow fill in the missing information using the overlay yaml instead of replacement.
base yaml:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- name: temp
image: temp
imagePullPolicy: Always
command: temp
args:
temp
envFrom:
- configMapRef:
name: temp
volumeMounts:
volumes:
overlay yaml:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
volumeMounts:
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
Expected result after kustomize build:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- name: temp
image: temp
imagePullPolicy: Always
command: temp
args:
["sleep 9000"]
envFrom:
- configMapRef:
name: temp
volumeMounts:
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
what i'm getting:
apiVersion: v1
kind: Pod
metadata:
labels:
tier: temp
name: temp
spec:
containers:
volumeMounts:
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
merge kubernetes yaml kustomize
i have a base yaml and an overlay yaml and using "kustomize" i want to merge these two yaml. what happens with me is that on running kustomize build there comes an output but it is not expected why? because the kustomize instead of filling the custom information from the overlay yaml replaces the whole heading tag of the base with the overlay "containers" in my case. The intended behaviour that i need is the it should somehow fill in the missing information using the overlay yaml instead of replacement.
base yaml:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- name: temp
image: temp
imagePullPolicy: Always
command: temp
args:
temp
envFrom:
- configMapRef:
name: temp
volumeMounts:
volumes:
overlay yaml:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
volumeMounts:
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
Expected result after kustomize build:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- name: temp
image: temp
imagePullPolicy: Always
command: temp
args:
["sleep 9000"]
envFrom:
- configMapRef:
name: temp
volumeMounts:
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
what i'm getting:
apiVersion: v1
kind: Pod
metadata:
labels:
tier: temp
name: temp
spec:
containers:
volumeMounts:
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
merge kubernetes yaml kustomize
merge kubernetes yaml kustomize
edited Jun 5 at 12:24
ITChap
4391 gold badge3 silver badges14 bronze badges
4391 gold badge3 silver badges14 bronze badges
asked Mar 27 at 12:50
user3030524user3030524
407 bronze badges
407 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
In your base.yaml
the value for the key containers
is a sequence (node). In your overlay.yaml
the value for the key containers
is a mapping. Of course those two cannot be merged.
Not knowing kustomize at all, it seems logical that because those cannot be merged, the overlay replaces that whole sequence node with the mapping node. Your expectation that the mapping of the overlay is merged with a mapping that happens to be an item (in this case the only item) in the sequence of the base seems completely arbitrary. Which item would need to be taken if there had been multiple items? The first? The last? The last one before item five that is a mapping?
If your overlay.yaml
looked like:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- volumeMounts: # < created a sequence item here by inserting an item indicator
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
then I could understand your expectation (and maybe the above change can be applied to make it work, I don't have a way to test).
add a comment |
I find that the easiest way to deal with this is to use JSONPatch. I would remove the empty fields of the base as in:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- name: temp
image: temp
imagePullPolicy: Always
command: temp
args:
temp
envFrom:
- configMapRef:
name: temp
Then in your overlay create a new patch, for example named create_volume.yml
:
- op: add
path: /spec/volumes/-
value:
name: temppathname
hostPath:
type: temp
path: temppath
- op: add
path: /spec/containers/0/volumeMounts/-
value:
name: temppathname
mountPath: /temppath
And finally in the overlay kustomization.yml
add:
patchesJson6902:
- target:
version: v1
kind: Pod
name: temp
path: create_volume.yml
If it doesn't work you might have to play with the API group in the patch target. I only patched deployments until now and my target would be:
- target:
group: apps
version: v1
kind: Deployment
name: temp
path: create_volume.yml
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377644%2fis-there-a-way-to-make-kustomize-merge-headings-in-a-yaml-file-instead-of-comple%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
In your base.yaml
the value for the key containers
is a sequence (node). In your overlay.yaml
the value for the key containers
is a mapping. Of course those two cannot be merged.
Not knowing kustomize at all, it seems logical that because those cannot be merged, the overlay replaces that whole sequence node with the mapping node. Your expectation that the mapping of the overlay is merged with a mapping that happens to be an item (in this case the only item) in the sequence of the base seems completely arbitrary. Which item would need to be taken if there had been multiple items? The first? The last? The last one before item five that is a mapping?
If your overlay.yaml
looked like:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- volumeMounts: # < created a sequence item here by inserting an item indicator
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
then I could understand your expectation (and maybe the above change can be applied to make it work, I don't have a way to test).
add a comment |
In your base.yaml
the value for the key containers
is a sequence (node). In your overlay.yaml
the value for the key containers
is a mapping. Of course those two cannot be merged.
Not knowing kustomize at all, it seems logical that because those cannot be merged, the overlay replaces that whole sequence node with the mapping node. Your expectation that the mapping of the overlay is merged with a mapping that happens to be an item (in this case the only item) in the sequence of the base seems completely arbitrary. Which item would need to be taken if there had been multiple items? The first? The last? The last one before item five that is a mapping?
If your overlay.yaml
looked like:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- volumeMounts: # < created a sequence item here by inserting an item indicator
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
then I could understand your expectation (and maybe the above change can be applied to make it work, I don't have a way to test).
add a comment |
In your base.yaml
the value for the key containers
is a sequence (node). In your overlay.yaml
the value for the key containers
is a mapping. Of course those two cannot be merged.
Not knowing kustomize at all, it seems logical that because those cannot be merged, the overlay replaces that whole sequence node with the mapping node. Your expectation that the mapping of the overlay is merged with a mapping that happens to be an item (in this case the only item) in the sequence of the base seems completely arbitrary. Which item would need to be taken if there had been multiple items? The first? The last? The last one before item five that is a mapping?
If your overlay.yaml
looked like:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- volumeMounts: # < created a sequence item here by inserting an item indicator
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
then I could understand your expectation (and maybe the above change can be applied to make it work, I don't have a way to test).
In your base.yaml
the value for the key containers
is a sequence (node). In your overlay.yaml
the value for the key containers
is a mapping. Of course those two cannot be merged.
Not knowing kustomize at all, it seems logical that because those cannot be merged, the overlay replaces that whole sequence node with the mapping node. Your expectation that the mapping of the overlay is merged with a mapping that happens to be an item (in this case the only item) in the sequence of the base seems completely arbitrary. Which item would need to be taken if there had been multiple items? The first? The last? The last one before item five that is a mapping?
If your overlay.yaml
looked like:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- volumeMounts: # < created a sequence item here by inserting an item indicator
- name: temppathname
mountPath: /temppath
volumes:
- name: temppathname
hostPath:
type: temp
path: temppath
then I could understand your expectation (and maybe the above change can be applied to make it work, I don't have a way to test).
answered Mar 27 at 15:38
AnthonAnthon
36.3k18 gold badges103 silver badges161 bronze badges
36.3k18 gold badges103 silver badges161 bronze badges
add a comment |
add a comment |
I find that the easiest way to deal with this is to use JSONPatch. I would remove the empty fields of the base as in:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- name: temp
image: temp
imagePullPolicy: Always
command: temp
args:
temp
envFrom:
- configMapRef:
name: temp
Then in your overlay create a new patch, for example named create_volume.yml
:
- op: add
path: /spec/volumes/-
value:
name: temppathname
hostPath:
type: temp
path: temppath
- op: add
path: /spec/containers/0/volumeMounts/-
value:
name: temppathname
mountPath: /temppath
And finally in the overlay kustomization.yml
add:
patchesJson6902:
- target:
version: v1
kind: Pod
name: temp
path: create_volume.yml
If it doesn't work you might have to play with the API group in the patch target. I only patched deployments until now and my target would be:
- target:
group: apps
version: v1
kind: Deployment
name: temp
path: create_volume.yml
add a comment |
I find that the easiest way to deal with this is to use JSONPatch. I would remove the empty fields of the base as in:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- name: temp
image: temp
imagePullPolicy: Always
command: temp
args:
temp
envFrom:
- configMapRef:
name: temp
Then in your overlay create a new patch, for example named create_volume.yml
:
- op: add
path: /spec/volumes/-
value:
name: temppathname
hostPath:
type: temp
path: temppath
- op: add
path: /spec/containers/0/volumeMounts/-
value:
name: temppathname
mountPath: /temppath
And finally in the overlay kustomization.yml
add:
patchesJson6902:
- target:
version: v1
kind: Pod
name: temp
path: create_volume.yml
If it doesn't work you might have to play with the API group in the patch target. I only patched deployments until now and my target would be:
- target:
group: apps
version: v1
kind: Deployment
name: temp
path: create_volume.yml
add a comment |
I find that the easiest way to deal with this is to use JSONPatch. I would remove the empty fields of the base as in:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- name: temp
image: temp
imagePullPolicy: Always
command: temp
args:
temp
envFrom:
- configMapRef:
name: temp
Then in your overlay create a new patch, for example named create_volume.yml
:
- op: add
path: /spec/volumes/-
value:
name: temppathname
hostPath:
type: temp
path: temppath
- op: add
path: /spec/containers/0/volumeMounts/-
value:
name: temppathname
mountPath: /temppath
And finally in the overlay kustomization.yml
add:
patchesJson6902:
- target:
version: v1
kind: Pod
name: temp
path: create_volume.yml
If it doesn't work you might have to play with the API group in the patch target. I only patched deployments until now and my target would be:
- target:
group: apps
version: v1
kind: Deployment
name: temp
path: create_volume.yml
I find that the easiest way to deal with this is to use JSONPatch. I would remove the empty fields of the base as in:
apiVersion: v1
kind: Pod
metadata:
name: temp
labels:
tier: temp
spec:
containers:
- name: temp
image: temp
imagePullPolicy: Always
command: temp
args:
temp
envFrom:
- configMapRef:
name: temp
Then in your overlay create a new patch, for example named create_volume.yml
:
- op: add
path: /spec/volumes/-
value:
name: temppathname
hostPath:
type: temp
path: temppath
- op: add
path: /spec/containers/0/volumeMounts/-
value:
name: temppathname
mountPath: /temppath
And finally in the overlay kustomization.yml
add:
patchesJson6902:
- target:
version: v1
kind: Pod
name: temp
path: create_volume.yml
If it doesn't work you might have to play with the API group in the patch target. I only patched deployments until now and my target would be:
- target:
group: apps
version: v1
kind: Deployment
name: temp
path: create_volume.yml
edited Jun 5 at 9:16
answered Jun 5 at 9:08
ITChapITChap
4391 gold badge3 silver badges14 bronze badges
4391 gold badge3 silver badges14 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377644%2fis-there-a-way-to-make-kustomize-merge-headings-in-a-yaml-file-instead-of-comple%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown