@media only screen and (max-width:991px){.lgUA-dd{display:block;}}/*!sc*/ @media only screen and (min-width:992px){.lgUA-dd{display:grid;grid-template-columns:20% 50% 30%;}}/*!sc*/ data-styled.g1[id="sc-bdnylx"]{content:"lgUA-dd,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){.jqIXaF{grid-row-start:3;grid-row-end:4;}}/*!sc*/ data-styled.g2[id="sc-gtssRu"]{content:"jqIXaF,"}/*!sc*/ @media only screen and (max-width:991px){.cWHJEl{height:50px;grid-row-start:1;grid-row-end:2;border-bottom:none;display:block;}}/*!sc*/ @media only screen and (min-width:992px){.cWHJEl{height:80px;grid-row-start:1;grid-row-end:2;border-bottom:1px solid var(--unaccepted-color);display:grid;grid-template-columns:80% 10% 10%;}}/*!sc*/ data-styled.g3[id="sc-dlnjPT"]{content:"cWHJEl,"}/*!sc*/ .jusCDq{font-family:'Roboto';}/*!sc*/ @media only screen and (max-width:991px){.jusCDq{margin-left:0;}}/*!sc*/ @media only screen and (min-width:992px){.jusCDq{margin-left:var(--margin);}}/*!sc*/ data-styled.g5[id="sc-eCApGN"]{content:"jusCDq,"}/*!sc*/ .kiTsHr{-webkit-text-decoration:none;text-decoration:none;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;background-color:papayawhip;border-radius:10px;padding:calc(var(--prism-padding)/4);}/*!sc*/ @media only screen and (max-width:991px){.kiTsHr{margin-left:auto;margin-right:auto;}}/*!sc*/ @media only screen and (min-width:992px){.kiTsHr{margin-left:0;margin-right:0;}}/*!sc*/ data-styled.g6[id="sc-jSFkmK"]{content:"kiTsHr,"}/*!sc*/ .gmemPO{-webkit-text-decoration:none;text-decoration:none;}/*!sc*/ @media only screen and (max-width:991px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ data-styled.g7[id="sc-gKAblj"]{content:"gmemPO,"}/*!sc*/ .hPRGzu{display:inline-block;color:#48c1eb;}/*!sc*/ @media only screen and (max-width:991px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ data-styled.g8[id="sc-iCoHVE"]{content:"hPRGzu,"}/*!sc*/ .jqApVD{display:inline-block;color:#b77eff;}/*!sc*/ @media only screen and (max-width:991px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ data-styled.g9[id="sc-fujyUd"]{content:"jqApVD,"}/*!sc*/ @media only screen and (max-width:991px){.diRbeU{grid-row-start:2;grid-row-end:3;}}/*!sc*/ @media only screen and (min-width:992px){.diRbeU{grid-column-start:1;grid-column-end:2;grid-row-start:2;grid-row-start:3;}}/*!sc*/ data-styled.g14[id="sc-crzoUp"]{content:"diRbeU,"}/*!sc*/ .bDYZtZ{border:3px var(--border-color) solid;box-shadow:var(--box-shadow-size) var(--box-shadow-size) var(--accepted-color);overflow-wrap:break-word;}/*!sc*/ @media only screen and (max-width:991px){.bDYZtZ{margin:0;padding:calc(var(--prism-padding) / 2);max-width:calc(100vw - calc(var(--prism-padding) / 0.4));}}/*!sc*/ @media only screen and (min-width:992px){.bDYZtZ{grid-column-start:1;grid-column-end:2;margin:var(--prism-padding);padding:var(--prism-padding);}}/*!sc*/ data-styled.g15[id="sc-dIsAE"]{content:"bDYZtZ,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g16[id="sc-bqGHjH"]{content:"jOGTxR,"}/*!sc*/ .hqplyp{color:gray;}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g17[id="sc-ksluoS"]{content:"hqplyp,"}/*!sc*/ .biJanX{text-align:right;font-style:italic;}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g18[id="sc-hBMVcZ"]{content:"biJanX,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g19[id="sc-fnVYJo"]{content:"hbxbBL,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g21[id="sc-bkbjAj"]{content:"jRzNCt,"}/*!sc*/ @media only screen and (max-width:991px){.bYuBoO{grid-row-start:3;grid-row-end:4;}}/*!sc*/ @media only screen and (min-width:992px){.bYuBoO{grid-column-start:2;grid-column-end:3;padding:calc(var(--prism-padding) /1);}}/*!sc*/ data-styled.g22[id="sc-iemXMA"]{content:"bYuBoO,"}/*!sc*/ .kUvyRY{box-shadow:var(--box-shadow-size) var(--box-shadow-size) var(--primary-color);overflow-wrap:break-word;padding:calc(var(--prism-padding) / 2);border:1px solid blue;margin:calc(var(--prism-padding) / 2);}/*!sc*/ @media only screen and (max-width:991px){.kUvyRY{display:block;margin-left:0;margin-right:calc(var(--prism-padding) / 4);}}/*!sc*/ @media only screen and (min-width:992px){.kUvyRY{display:inline-block;}}/*!sc*/ data-styled.g23[id="sc-dIvqjp"]{content:"kUvyRY,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){.kgfarp{-webkit-text-decoration:none;text-decoration:none;}}/*!sc*/ data-styled.g24[id="sc-hHEjAm"]{content:"kgfarp,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){.jhbzHN{margin:calc(var(--prism-padding) / 4);}}/*!sc*/ data-styled.g25[id="sc-dlMBXb"]{content:"jhbzHN,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){.ipBxef{float:right;padding-top:var(--prism-padding);}}/*!sc*/ data-styled.g26[id="sc-kfYqjs"]{content:"ipBxef,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){.fNfboX{display:inline-block;padding:calc(var(--prism-padding) / 4);border:1px solid var(--secondary-color);color:var(--secondary-color);margin-right:calc(var(--prism-padding) / 4);margin-bottom:calc(var(--prism-padding) / 4);}}/*!sc*/ data-styled.g27[id="sc-fKgIGh"]{content:"fNfboX,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g28[id="sc-bCwgka"]{content:"kCbTfo,"}/*!sc*/ .eohSKo{color:gray;}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g29[id="sc-iwaifL"]{content:"eohSKo,"}/*!sc*/ .dvQjiN{text-align:right;font-style:italic;}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g30[id="sc-cxNIbT"]{content:"dvQjiN,"}/*!sc*/ @media only screen and (max-width:991px){}/*!sc*/ @media only screen and (min-width:992px){.lnacFT{grid-column-start:2;grid-column-end:4;}}/*!sc*/ data-styled.g31[id="sc-lmgQde"]{content:"lnacFT,"}/*!sc*/ @media only screen and (max-width:991px){.dmJaPZ{padding:calc(var(--prism-padding) / 2);display:grid;grid-template-rows:auto auto auto;}}/*!sc*/ @media only screen and (min-width:992px){.dmJaPZ{padding:0;display:grid;grid-template-columns:62.5% 37.5%;grid-template-rows:auto auto;}}/*!sc*/ data-styled.g32[id="sc-iJCRLp"]{content:"dmJaPZ,"}/*!sc*/ .jVqPkz{border:3px solid var(--border-color);box-shadow:var(--box-shadow-size) var(--box-shadow-size) var(--primary-color);grid-row-start:1;grid-row-end:2;overflow-wrap:break-word;}/*!sc*/ @media only screen and (max-width:991px){.jVqPkz{padding:calc(var(--prism-padding) / 2);max-width:calc(100vw - calc(var(--prism-padding) / 0.4));}}/*!sc*/ @media only screen and (min-width:992px){.jVqPkz{margin:var(--prism-padding);padding:var(--prism-padding);}}/*!sc*/ data-styled.g33[id="sc-giAqnE"]{content:"jVqPkz,"}/*!sc*/ @media only screen and (max-width:600px){}/*!sc*/ @media only screen and (min-width:600px){}/*!sc*/ @media only screen and (min-width:768px){}/*!sc*/ @media only screen and (min-width:992px){}/*!sc*/ @media only screen and (min-width:1200px){}/*!sc*/ data-styled.g34[id="sc-ezzayL"]{content:"kJKIJS,"}/*!sc*/ body{position:absolute;top:0;margin:0;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Roboto','Oxygen', 'Ubuntu','Cantarell','Fira Sans','Droid Sans','Helvetica Neue', sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;--prism-padding:20px;--margin:1.62em;--box-shadow-size:6px;--box-shadow:var(--box-shadow-size) var(--box-shadow-size) var(--primary-color);--box-shadow-hover:10px 10px var(--primary-color);--easing:200ms ease-in-out;--primary-color:#cdf2ff;--accepted-color:#bbffb8;--unaccepted-color:#eee;--border-color:#c8c8c8;--secondary-color:#9547b7;--dark-color:#282936;height:100vh;width:100%;}/*!sc*/ #root{height:100%;}/*!sc*/ h1{display:block;font-size:2em;margin-block-start:0.67em;margin-block-end:0.67em;margin-inline-start:0px;margin-inline-end:0px;font-weight:bold;}/*!sc*/ h2{display:block;font-size:1.5em;margin-block-start:0.83em;margin-block-end:0.83em;margin-inline-start:0px;margin-inline-end:0px;font-weight:bold;}/*!sc*/ img{width:100%;}/*!sc*/ pre{overflow-wrap:auto;overflow-x:scroll;}/*!sc*/ blockquote{border-left:2px solid var(--unaccepted-color);margin-block-start:0px;margin-inline-start:0px;padding-left:20px;}/*!sc*/ data-styled.g45[id="sc-global-bcwoHH1"]{content:"sc-global-bcwoHH1,"}/*!sc*/ gt; kubectl apply -f ./hello-world.yaml The Deployment "my-deployment" is invalid: spec.template.metadata.labels: Invalid value: map[string]string{"app":"b..."/>

The Deployment "my-deployment" is invalid

6/27/2019

I have created a very basic deployment for Kubernetes, but when I try to deploy it

gt; kubectl apply -f ./hello-world.yaml
The Deployment "my-deployment" is invalid: spec.template.metadata.labels: Invalid value: map[string]string{"app":"bbbb"}: `selector` does not match template `labels`

With the following yaml file:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
  labels:
    app: aaaa
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-deployment
  template:
    metadata:
      labels:
        app: bbbb
    spec:
      containers:
      - name: my-deploy
        image: hello-world
        ports:
        - containerPort: 80

I have played with the labels and matchLabels a bit, but couldn't fix it. Any suggestions what might be the issue?

-- Jeanluca Scaljeri
kubernetes

1 Answer

6/27/2019

Basically, the selector match label in your deployment spec needs to match a label in your template. In your case, you have app: my-deployment as a matching label for the selector and you have app: bbbb in your template, so no match.

You would have to have something either one app: my-deployment or app: bbbb on both so that there is a match.

-- Rico
Source: StackOverflow