@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*/ #x27; Here is how I have define..."/>

Kubernetes: How to pass pipe character in readiness probe command

11/19/2019

I am having an issue with passing a pipe character | in readiness probe command.

I want to have a probe command:

curl --silent http://localhost:8080/actuator/health | grep --quiet -e '^{\"status\"\:\"UP\".*}

#x27;

Here is how I have defined the probe:

# kubectl get pod my_pod -o yaml

readinessProbe:
  exec:
    command:
    - curl
    - --silent
    - http://localhost:8080/actuator/health
    - '|'
    - grep
    - --quiet
    - -e
    - '''^{\"status\"\:\"UP\".*}
#x27;''

Readiness probe fails with a message:

Readiness probe failed: curl: option --quiet: is unknown curl: try 'curl --help' or 'curl --manual' for more information

The error can be reproduce when command is executed without pipe character |:

curl --silent http://localhost:8080/actuator/health grep --quiet -e '^{\"status\"\:\"UP\".*}

#x27;

For some reason pipe is not interpreted by Kubernetes.

Can you please help me with passing pipe in deployment?

-- Michal Foksa
kubernetes
openshift

1 Answer

11/19/2019

Kubernetes doesn't run a shell to process commands on its own; it just runs them directly. The closest equivalent in a shell would be

curl '--silent' 'http://...' '|' 'grep' ...

That is, | here doesn't split two separate commands, because that's shell syntax; without a shell it becomes another parameter to curl, as do all of the words after it.

You need to provide the shell wrapper yourself:

readinessProbe:
  exec:
    command:
      - sh
      - -c
      - curl --silent http://localhost:8080/actuator/health | grep --quiet -e '^{\"status\"\:\"UP\".*}
#x27;

You can use alternate YAML syntax to make this a little more readable. (> means to fold following lines into a single string; - means to strip leading and trailing whitespace.

readinessProbe:
  exec:
    command:
      - sh
      - -c
      - >-
         curl --silent http://localhost:8080/actuator/health |
         grep --quiet -e '^{\"status\"\:\"UP\".*}
#x27;
-- David Maze
Source: StackOverflow