bug-fix: kubectl not installed in Bottlenecks docker
[bottlenecks.git] / utils / k8s_setup / kubectl_install.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2018 Huawei Tech and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 OS_TYPE=$(uname -a)
12 OS_UBUNTU=$(echo $OS_TYPE | grep Ubuntu)
13
14 if [[ $OS_UBUNTU ]]; then
15     apt-get update && apt-get install -y apt-transport-https
16     curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
17     touch /etc/apt/sources.list.d/kubernetes.list
18     echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list
19     apt-get update
20     apt-get install -y kubectl
21 else
22     cat <<EOF > /etc/yum.repos.d/kubernetes.repo
23 [kubernetes]
24 name=Kubernetes
25 baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
26 enabled=1
27 gpgcheck=1
28 repo_gpgcheck=1
29 gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
30 EOF
31     yum install -y kubectl
32 fi
33