在httpHeaders中将k8s秘密用于livenessProbe

时间:2019-07-24 08:49:55

标签: kubernetes-helm

我想为我的服务做一个livenessProbe。

但是,此服务需要带有机密内容的特殊http-header。机密存储在k8s机密中。如何在头盔图表中访问它?

我尝试过:

please replace with script with this.




function showTab(n) {
  // This function will display the specified tab of the form...
  var x = document.getElementsByClassName("tab");

  x[n].style.display = "block";
  //... and fix the Previous/Next buttons:
  if (n == 0) {
    document.getElementById("prevBtn").style.display = "none";
  } else {
    document.getElementById("prevBtn").style.display = "inline";
  }
  if (n == (x.length - 1)) {
    document.getElementById("nextBtn").innerHTML = "Submit";
  } else {
    document.getElementById("nextBtn").innerHTML = "Next";
  }
  //... and run a function that will display the correct step indicator:
  fixStepIndicator(n)
}

function nextPrev(n) {
  // This function will figure out which tab to display
  var x = document.getElementsByClassName("tab");

  // Exit the function if any field in the current tab is invalid:
  if (n == 1 && !validateForm(currentTab)) return false;
  // Hide the current tab:
  x[currentTab].style.display = "none";
  // Increase or decrease the current tab by 1:
  currentTab = currentTab + n;
  // if you have reached the end of the form...
  if (currentTab >= x.length) {
    // ... the form gets submitted:
    document.getElementById("regForm").submit();
    return false;
  }
  // Otherwise, display the correct tab:
  showTab(currentTab);
}

function validateForm(currentTab) {
  // This function deals with validation of the form fields
  var x, y, i, valid = true;
  x = document.getElementsByClassName("tab");
  y = x[currentTab].getElementsByTagName("input");
 switch(currentTab){
        case 0:
        if(x[currentTab].querySelectorAll('input[name="thing"]:checked').length < 1)
        {
             alert("Must check some thing!");
             return false
        }else{
                document.getElementsByClassName("step")[currentTab].className += " finish";

        }
        return true;
        break;
        case 1:
        if(x[currentTab].querySelectorAll('input[name="size"]:checked').length < 1)
        {
             alert("Must check some thing!");
             return false
        }
        else{

                document.getElementsByClassName("step")[currentTab].className += " finish";

        }
        return true;
        break;
        case 3:
        if(x[currentTab].querySelectorAll('input[name="size"]:checked').length < 1)
        {
             alert("Must check some thing!");
             return false
        }
        else{

                document.getElementsByClassName("step")[currentTab].className += " finish";
            }
        return true;
        break;
        default:
            for (i = 0; i < y.length; i++) {
        // If a field is empty...
        if (y[i].value == "") {
          // add an "invalid" class to the field:
          y[i].className += " invalid";
          // and set the current valid status to false:
          valid = false;
        }
      }


 }

  // A loop that checks every input field in the current tab:

  // If the valid status is true, mark the step as finished and valid:

  if (valid) {

    document.getElementsByClassName("step")[currentTab].className += " finish";
  }
  return valid; // return the valid status
}

function fixStepIndicator(n) {
  // This function removes the "active" class of all steps...
  var i, x = document.getElementsByClassName("step");
  for (i = 0; i < x.length; i++) {
    x[i].className = x[i].className.replace(" active", "");
  }
  //... and adds the "active" class on the current step:
  x[n].className += " active";
}

livenessProbe:
          httpGet:
            path: /health
            port: 5100
            httpHeaders:
              - name: x-api-key
                value: $MY_API_KEY

但是,这不起作用。

我认为解决方法是编写一个包装curl调用的bash脚本。这个脚本应该阅读环境吧? 但是有更好的方法吗?

0 个答案:

没有答案