github.com/galamsiva2020/kubernetes-heapster-monitoring@v0.0.0-20210823134957-3c1baa7c1e70/deploy/kube-config/standalone-with-apiserver/startup.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright 2016 The Kubernetes Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  
    18  # DEVELOPMENT ONLY
    19  #
    20  # This script helps build the environment for the Heapster API server.
    21  # It is best to have the service running first:
    22  #   ${KUBE_ROOT}/cluster/kubectl.sh --namespace=${HEAPSTER_NAMESPACE} \
    23  #       create -f "${HEAPSTER_ROOT}/deploy/kube-config/standalone-with-apiserver/heapster-service.yaml",
    24  #
    25  # Once it is assigned the external IP, run this script to generate the needed certificates,
    26  # basic auth config and kubeconfig, which will be stored in
    27  # ${HEAPSTER_ROOT}/deploy/kube-config/standalone-with-apiserver/tmp/heapster/kubeconfig.
    28  #
    29  # It will also create the following objects in the ${HEAPSTER_NAMESPACE} namespace:
    30  #   -  "heapster-apiserver-kubeconfig" secret
    31  #   -  "heapster-apiserver-secrets" secret
    32  #   -  deployment "heapster-apiserver"
    33  #
    34  
    35  # set these to the roots of kubernetes and heapster repos
    36  KUBE_ROOT=$HOME/go/src/k8s.io/kubernetes
    37  HEAPSTER_ROOT=$HOME/go/src/k8s.io/heapster
    38  
    39  HEAPSTER_NAMESPACE=${HEAPSTER_NAMESPACE:-"kube-system"}
    40  HEAPSTER_DEPLOYMENT_NAME=${HEAPSTER_DEPLOYMENT_NAME:-"heapster-apiserver"}
    41  
    42  manifests_root="${HEAPSTER_ROOT}/deploy/kube-config/standalone-with-apiserver"
    43  host_kubectl="${KUBE_ROOT}/cluster/kubectl.sh --namespace=${HEAPSTER_NAMESPACE}"
    44  
    45  # If not yet created, create the service
    46  #$host_kubectl create -f "${manifests_root}/heapster-service.yaml"
    47  HEAPSTER_API_HOST="$($host_kubectl get -o=jsonpath svc/${HEAPSTER_DEPLOYMENT_NAME} --template '{.status.loadBalancer.ingress[*].ip}')"
    48  
    49  source "${manifests_root}/common.sh"
    50  
    51  ### certificates
    52  CONTEXT="heapster-apiserver"
    53  MASTER_NAME="${HEAPSTER_DEPLOYMENT_NAME}" KUBE_TEMP="${HEAPSTER_ROOT}/deploy/kube-config/standalone-with-apiserver/tmp" create-apiserver-certs ${HEAPSTER_API_HOST}
    54  echo "Generated certs"
    55  
    56  ### basic auth
    57  KUBE_TEMP="${manifests_root}/tmp"
    58  KUBECONFIG="${KUBE_TEMP}/heapster/kubeconfig"
    59  create-auth-config
    60  echo "Generated basic auth"
    61  
    62  ### kubeconfig file
    63  create-heapster-kubeconfig
    64  
    65  ### create kubeconfig secret
    66  KUBECONFIG="${KUBE_TEMP}/heapster/kubeconfig"
    67  $host_kubectl create secret generic heapster-apiserver-kubeconfig --from-file="${KUBECONFIG}"
    68  
    69  ### fill the template with generated values
    70  template="go run ${KUBE_ROOT}/federation/cluster/template.go"
    71  $template "${manifests_root}/heapster-apiserver-secrets.template" > "${manifests_root}/heapster-apiserver-secrets.yaml"
    72  
    73  # create secret and deployment
    74  $host_kubectl create -f "${manifests_root}/heapster-apiserver-secrets.yaml"
    75  $host_kubectl create -f "${manifests_root}/heapster-deployment.yaml"