Force PersistentVolumeClaim and Deployment to land in same availability zoneKubectl apply for a deployment with revHistoryLimit 0 does not delete the old replica set, here is my deploment templateKubernetes doesn't allow to mount file to containerGoogle Kubernetes Engine: Not seeing mount persistent volume in the instanceHow to mount a volume with a windows container in kubernetes?Share nfs volume between kubernetes clustersPersistentVolume marked as bound but invisible in containersAccess stateful headless kubernetes externally?Not able to see Pod when I create a Jobkubernetes deployment with argskubeadm install flannel get error, what's wrong?

My large rocket is still flipping over

What does the coin flipping before dying mean?

How is trade in services conducted under the WTO in the absence of the Doha conclusion?

Summer '19 Sandbox error: String index out of range: 0: Source

Reverse ColorFunction or ColorData

Endgame puzzle: How to avoid stalemate and win?

What detail can Hubble see on Mars?

Emergency stop in plain TeX, pdfTeX, XeTeX and LuaTeX?

TIP120 Transistor + Solenoid Failing Randomly

Has the United States ever had a non-Christian President?

Dimmer switch not connected to ground

Efficient deletion of specific list entries

How do I, as a DM, handle a party that decides to set up an ambush in a dungeon?

Copper as an adjective to refer to something made of copper

Transistor gain, what if there is not enough current?

What happens if I accidentally leave an app running and click "Install Now" in Software Updater?

How to say something covers all the view up to the horizon line?

What does のそ mean on this picture?

Is there a reason why Turkey took the Balkan territories of the Ottoman Empire, instead of Greece or another of the Balkan states?

Installing Debian 10, upgrade to stable later?

How long did it take Captain Marvel to travel to Earth?

What do you call a painting painted on a wall?

What is a common way to tell if an academic is "above average," or outstanding in their field? Is their h-index (Hirsh index) one of them?

Was there a dinosaur-counter in the original Jurassic Park movie?



Force PersistentVolumeClaim and Deployment to land in same availability zone


Kubectl apply for a deployment with revHistoryLimit 0 does not delete the old replica set, here is my deploment templateKubernetes doesn't allow to mount file to containerGoogle Kubernetes Engine: Not seeing mount persistent volume in the instanceHow to mount a volume with a windows container in kubernetes?Share nfs volume between kubernetes clustersPersistentVolume marked as bound but invisible in containersAccess stateful headless kubernetes externally?Not able to see Pod when I create a Jobkubernetes deployment with argskubeadm install flannel get error, what's wrong?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have a kubernetes cluster in AWS with ec2 worker nodes in the following AZs along with corresponding PersistentVolumes in each AZ.



us-west-2a
us-west-2b
us-west-2c
us-west-2d


My problem is I want to create a Deployment with a volume mount that references a PersistentVolumeClaim and guarantee they land in the same AZ because right now it is luck whether both the Deployment and PersistentVolumeClaim end up in the same AZ. If they don't land in the same AZ then the deployment fails to find the volume mount.



I create 4 PersistentVolumes by manually creates EBS volumes in each AZ and copying the ID to the spec.




"apiVersion": "v1",
"kind": "PersistentVolume",
"metadata":
"name": "pv-2"
,
"spec":
"capacity":
"storage": "1Gi"
,
"accessModes": [
"ReadWriteOnce"
],
"persistentVolumeReclaimPolicy": "Retain",
"awsElasticBlockStore":
"volumeID": "vol-053f78f0c16e5f20e",
"fsType": "ext4"






"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata":
"name": "mydata",
"namespace": "staging"
,
"spec":
"accessModes": [
"ReadWriteOnce"
],
"resources":
"requests":
"storage": "10Mi"







"apiVersion": "extensions/v1beta1",
"kind": "Deployment",
"metadata":
"name": "myapp",
"namespace": "default",
"labels":
"app": "myapp"

,
"spec":
"replicas": 1,
"selector":
"matchLabels":
"app": "myapp"

,
"template":
"metadata":
"labels":
"app": "myapp"

,
"spec":
"containers": [

"name": "hello",
"image": "centos:7",
"volumeMounts": [
"name":"mydata",
"mountPath":"/etc/data/"
]

],
"volumes": [
"name":"mydata",
"persistentVolumeClaim":
"claimName":"mydata"

]














share|improve this question

















  • 1





    "...because right now it is luck whether both the Deployment and PersistentVolumeClaim end up in the same AZ..." It's not luck. see kubernetes.io/docs/setup/multiple-zones/#functionality

    – wineinlib
    Mar 23 at 5:54












  • I create the PersistentVolumeClaim first and the Deployment does get consistently scheduled in the same AZ.

    – Mike
    Mar 23 at 7:08

















0















I have a kubernetes cluster in AWS with ec2 worker nodes in the following AZs along with corresponding PersistentVolumes in each AZ.



us-west-2a
us-west-2b
us-west-2c
us-west-2d


My problem is I want to create a Deployment with a volume mount that references a PersistentVolumeClaim and guarantee they land in the same AZ because right now it is luck whether both the Deployment and PersistentVolumeClaim end up in the same AZ. If they don't land in the same AZ then the deployment fails to find the volume mount.



I create 4 PersistentVolumes by manually creates EBS volumes in each AZ and copying the ID to the spec.




"apiVersion": "v1",
"kind": "PersistentVolume",
"metadata":
"name": "pv-2"
,
"spec":
"capacity":
"storage": "1Gi"
,
"accessModes": [
"ReadWriteOnce"
],
"persistentVolumeReclaimPolicy": "Retain",
"awsElasticBlockStore":
"volumeID": "vol-053f78f0c16e5f20e",
"fsType": "ext4"






"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata":
"name": "mydata",
"namespace": "staging"
,
"spec":
"accessModes": [
"ReadWriteOnce"
],
"resources":
"requests":
"storage": "10Mi"







"apiVersion": "extensions/v1beta1",
"kind": "Deployment",
"metadata":
"name": "myapp",
"namespace": "default",
"labels":
"app": "myapp"

,
"spec":
"replicas": 1,
"selector":
"matchLabels":
"app": "myapp"

,
"template":
"metadata":
"labels":
"app": "myapp"

,
"spec":
"containers": [

"name": "hello",
"image": "centos:7",
"volumeMounts": [
"name":"mydata",
"mountPath":"/etc/data/"
]

],
"volumes": [
"name":"mydata",
"persistentVolumeClaim":
"claimName":"mydata"

]














share|improve this question

















  • 1





    "...because right now it is luck whether both the Deployment and PersistentVolumeClaim end up in the same AZ..." It's not luck. see kubernetes.io/docs/setup/multiple-zones/#functionality

    – wineinlib
    Mar 23 at 5:54












  • I create the PersistentVolumeClaim first and the Deployment does get consistently scheduled in the same AZ.

    – Mike
    Mar 23 at 7:08













0












0








0








I have a kubernetes cluster in AWS with ec2 worker nodes in the following AZs along with corresponding PersistentVolumes in each AZ.



us-west-2a
us-west-2b
us-west-2c
us-west-2d


My problem is I want to create a Deployment with a volume mount that references a PersistentVolumeClaim and guarantee they land in the same AZ because right now it is luck whether both the Deployment and PersistentVolumeClaim end up in the same AZ. If they don't land in the same AZ then the deployment fails to find the volume mount.



I create 4 PersistentVolumes by manually creates EBS volumes in each AZ and copying the ID to the spec.




"apiVersion": "v1",
"kind": "PersistentVolume",
"metadata":
"name": "pv-2"
,
"spec":
"capacity":
"storage": "1Gi"
,
"accessModes": [
"ReadWriteOnce"
],
"persistentVolumeReclaimPolicy": "Retain",
"awsElasticBlockStore":
"volumeID": "vol-053f78f0c16e5f20e",
"fsType": "ext4"






"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata":
"name": "mydata",
"namespace": "staging"
,
"spec":
"accessModes": [
"ReadWriteOnce"
],
"resources":
"requests":
"storage": "10Mi"







"apiVersion": "extensions/v1beta1",
"kind": "Deployment",
"metadata":
"name": "myapp",
"namespace": "default",
"labels":
"app": "myapp"

,
"spec":
"replicas": 1,
"selector":
"matchLabels":
"app": "myapp"

,
"template":
"metadata":
"labels":
"app": "myapp"

,
"spec":
"containers": [

"name": "hello",
"image": "centos:7",
"volumeMounts": [
"name":"mydata",
"mountPath":"/etc/data/"
]

],
"volumes": [
"name":"mydata",
"persistentVolumeClaim":
"claimName":"mydata"

]














share|improve this question














I have a kubernetes cluster in AWS with ec2 worker nodes in the following AZs along with corresponding PersistentVolumes in each AZ.



us-west-2a
us-west-2b
us-west-2c
us-west-2d


My problem is I want to create a Deployment with a volume mount that references a PersistentVolumeClaim and guarantee they land in the same AZ because right now it is luck whether both the Deployment and PersistentVolumeClaim end up in the same AZ. If they don't land in the same AZ then the deployment fails to find the volume mount.



I create 4 PersistentVolumes by manually creates EBS volumes in each AZ and copying the ID to the spec.




"apiVersion": "v1",
"kind": "PersistentVolume",
"metadata":
"name": "pv-2"
,
"spec":
"capacity":
"storage": "1Gi"
,
"accessModes": [
"ReadWriteOnce"
],
"persistentVolumeReclaimPolicy": "Retain",
"awsElasticBlockStore":
"volumeID": "vol-053f78f0c16e5f20e",
"fsType": "ext4"






"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata":
"name": "mydata",
"namespace": "staging"
,
"spec":
"accessModes": [
"ReadWriteOnce"
],
"resources":
"requests":
"storage": "10Mi"







"apiVersion": "extensions/v1beta1",
"kind": "Deployment",
"metadata":
"name": "myapp",
"namespace": "default",
"labels":
"app": "myapp"

,
"spec":
"replicas": 1,
"selector":
"matchLabels":
"app": "myapp"

,
"template":
"metadata":
"labels":
"app": "myapp"

,
"spec":
"containers": [

"name": "hello",
"image": "centos:7",
"volumeMounts": [
"name":"mydata",
"mountPath":"/etc/data/"
]

],
"volumes": [
"name":"mydata",
"persistentVolumeClaim":
"claimName":"mydata"

]











amazon-web-services kubernetes persistent-volumes aws-ebs persistent-volume-claims






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 23 at 4:42









MikeMike

1471216




1471216







  • 1





    "...because right now it is luck whether both the Deployment and PersistentVolumeClaim end up in the same AZ..." It's not luck. see kubernetes.io/docs/setup/multiple-zones/#functionality

    – wineinlib
    Mar 23 at 5:54












  • I create the PersistentVolumeClaim first and the Deployment does get consistently scheduled in the same AZ.

    – Mike
    Mar 23 at 7:08












  • 1





    "...because right now it is luck whether both the Deployment and PersistentVolumeClaim end up in the same AZ..." It's not luck. see kubernetes.io/docs/setup/multiple-zones/#functionality

    – wineinlib
    Mar 23 at 5:54












  • I create the PersistentVolumeClaim first and the Deployment does get consistently scheduled in the same AZ.

    – Mike
    Mar 23 at 7:08







1




1





"...because right now it is luck whether both the Deployment and PersistentVolumeClaim end up in the same AZ..." It's not luck. see kubernetes.io/docs/setup/multiple-zones/#functionality

– wineinlib
Mar 23 at 5:54






"...because right now it is luck whether both the Deployment and PersistentVolumeClaim end up in the same AZ..." It's not luck. see kubernetes.io/docs/setup/multiple-zones/#functionality

– wineinlib
Mar 23 at 5:54














I create the PersistentVolumeClaim first and the Deployment does get consistently scheduled in the same AZ.

– Mike
Mar 23 at 7:08





I create the PersistentVolumeClaim first and the Deployment does get consistently scheduled in the same AZ.

– Mike
Mar 23 at 7:08












1 Answer
1






active

oldest

votes


















1














You could try setting annotation for region and AvailabilityZone as mentioned in here and here






share|improve this answer























    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
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55310673%2fforce-persistentvolumeclaim-and-deployment-to-land-in-same-availability-zone%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You could try setting annotation for region and AvailabilityZone as mentioned in here and here






    share|improve this answer



























      1














      You could try setting annotation for region and AvailabilityZone as mentioned in here and here






      share|improve this answer

























        1












        1








        1







        You could try setting annotation for region and AvailabilityZone as mentioned in here and here






        share|improve this answer













        You could try setting annotation for region and AvailabilityZone as mentioned in here and here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 24 at 16:02









        jijojijo

        585




        585





























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55310673%2fforce-persistentvolumeclaim-and-deployment-to-land-in-same-availability-zone%23new-answer', 'question_page');

            );

            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







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript