Skip to content

Commit 90daa35

Browse files
committed
Add setup scripts for Linux (ubuntu and centos)
1 parent ea21733 commit 90daa35

File tree

4 files changed

+224
-2
lines changed

4 files changed

+224
-2
lines changed

SETUP.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ section.
3434

3535
### Auto-Install on Windows
3636

37+
*(This was tested on Windows 10)*
38+
3739
I recommend installing [Git for Windows](https://gitforwindows.org), and use the
3840
Git Bash application for cloning the repository, executing the setup script, and
3941
going through the exercises of this workshop.
@@ -75,7 +77,20 @@ section.
7577

7678
### Auto-Install on Linux
7779

78-
In progress...
80+
*(This was tested on Ubuntu trusty and CentOS 7)*
81+
82+
You can run the [`setup-workstation.sh`](./setup-workstation.sh) script to
83+
install the required tools. Make sure you run it as `root`:
84+
85+
```shell
86+
$ sudo ./setup-workstation.sh
87+
```
88+
89+
On CentOS 7, you need to start the Docker service:
90+
91+
```shell
92+
$ sudo service docker start
93+
```
7994

8095
Then you can continue to the
8196
[Google Cloud Platform Account Setup](#google-cloud-platform-account-setup)
@@ -92,7 +107,8 @@ can create a project for the workshop and name it "DevOps Workshop".
92107

93108
## Download large files
94109

95-
1. **Docker Images**: download the following Docker images by running:
110+
1. **Docker Images**: download the following Docker images by running (use
111+
`sudo` on Linux):
96112
* `docker pull openjdk:8-jdk-alpine`
97113
* `docker pull mysql:5.7`
98114
* `docker pull dtsato/gomatic`

setup-workstation.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,15 @@ case $OSTYPE in
88
msys*)
99
setup/windows.ps1
1010
;;
11+
linux*)
12+
DISTRO=$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr '"' '\0')
13+
case $DISTRO in
14+
ubuntu|debian)
15+
source setup/ubuntu.sh
16+
;;
17+
centos|rhel|fedora)
18+
source setup/centos.sh
19+
;;
20+
esac
21+
;;
1122
esac

setup/centos.sh

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
4+
echo "Not running as root"
5+
exit
6+
fi
7+
8+
curl -so /etc/yum.repos.d/virtualbox.repo http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
9+
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
10+
[kubernetes]
11+
name=Kubernetes
12+
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
13+
enabled=1
14+
gpgcheck=1
15+
repo_gpgcheck=1
16+
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
17+
EOF
18+
sudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo << EOF
19+
[google-cloud-sdk]
20+
name=Google Cloud SDK
21+
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
22+
enabled=1
23+
gpgcheck=1
24+
repo_gpgcheck=1
25+
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
26+
EOF
27+
yum update -y
28+
yum install -y unzip
29+
30+
PACKAGES_TO_INSTALL=""
31+
32+
if hash javac 2>/dev/null; then
33+
echo "Java is already installed!"
34+
else
35+
echo "Installing Java..."
36+
PACKAGES_TO_INSTALL+=" java-1.8.0-openjdk"
37+
fi
38+
39+
if hash git 2>/dev/null; then
40+
echo "Git is already installed!"
41+
else
42+
echo "Installing Git..."
43+
PACKAGES_TO_INSTALL+=" git"
44+
fi
45+
46+
if hash VBoxManage 2>/dev/null; then
47+
echo "VirtualBox is already installed!"
48+
else
49+
echo "Installing VirtualBox..."
50+
PACKAGES_TO_INSTALL+=" binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms VirtualBox-5.2"
51+
fi
52+
53+
if hash docker 2>/dev/null; then
54+
echo "Docker is already installed!"
55+
else
56+
echo "Installing Docker..."
57+
PACKAGES_TO_INSTALL+=" docker"
58+
fi
59+
60+
if hash kubectl 2>/dev/null; then
61+
echo "Kubectl is already installed!"
62+
else
63+
echo "Installing kubectl..."
64+
PACKAGES_TO_INSTALL+=" kubectl"
65+
fi
66+
67+
if hash gcloud 2>/dev/null; then
68+
echo "Google Cloud SDK is already installed!"
69+
else
70+
echo "Installing Google Cloud SDK..."
71+
PACKAGES_TO_INSTALL+=" google-cloud-sdk"
72+
fi
73+
74+
yum install -y $PACKAGES_TO_INSTALL
75+
76+
if hash minikube 2>/dev/null; then
77+
echo "Minikube is already installed!"
78+
else
79+
echo "Installing minikube..."
80+
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.25.2/minikube-linux-amd64
81+
chmod +x minikube
82+
mv minikube /usr/local/bin/
83+
fi
84+
85+
if hash terraform 2>/dev/null; then
86+
echo "Terraform is already installed!"
87+
else
88+
echo "Installing terraform..."
89+
curl -Lo terraform.zip https://releases.hashicorp.com/terraform/0.11.7/terraform_0.11.7_linux_amd64.zip
90+
unzip terraform.zip
91+
mv terraform /usr/local/bin/
92+
rm terraform.zip
93+
fi
94+
95+
if hash helm 2>/dev/null; then
96+
echo "Helm is already installed!"
97+
else
98+
echo "Installing Helm..."
99+
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh
100+
chmod 700 get_helm.sh
101+
./get_helm.sh
102+
rm get_helm.sh
103+
fi

setup/ubuntu.sh

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
4+
echo "Not running as root"
5+
exit
6+
fi
7+
8+
apt-get update && apt-get install -y apt-transport-https unzip
9+
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
10+
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
11+
deb http://apt.kubernetes.io/ kubernetes-xenial main
12+
EOF
13+
CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"
14+
cat <<EOF >/etc/apt/sources.list.d/google-cloud-sdk.list
15+
deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main
16+
EOF
17+
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
18+
apt-get update
19+
20+
PACKAGES_TO_INSTALL=""
21+
if hash javac 2>/dev/null; then
22+
echo "Java is already installed!"
23+
else
24+
echo "Installing Java..."
25+
PACKAGES_TO_INSTALL+=" default-jdk"
26+
fi
27+
28+
if hash git 2>/dev/null; then
29+
echo "Git is already installed!"
30+
else
31+
echo "Installing Git..."
32+
PACKAGES_TO_INSTALL+=" git"
33+
fi
34+
35+
if hash VBoxManage 2>/dev/null; then
36+
echo "VirtualBox is already installed!"
37+
else
38+
echo "Installing VirtualBox..."
39+
PACKAGES_TO_INSTALL+=" virtualbox"
40+
fi
41+
42+
if hash docker 2>/dev/null; then
43+
echo "Docker is already installed!"
44+
else
45+
echo "Installing Docker..."
46+
PACKAGES_TO_INSTALL+=" docker.io"
47+
fi
48+
49+
if hash kubectl 2>/dev/null; then
50+
echo "Kubectl is already installed!"
51+
else
52+
echo "Installing kubectl..."
53+
PACKAGES_TO_INSTALL+=" kubectl"
54+
fi
55+
56+
if hash gcloud 2>/dev/null; then
57+
echo "Google Cloud SDK is already installed!"
58+
else
59+
echo "Installing Google Cloud SDK..."
60+
PACKAGES_TO_INSTALL+=" google-cloud-sdk"
61+
fi
62+
63+
apt-get install -y $PACKAGES_TO_INSTALL
64+
65+
if hash minikube 2>/dev/null; then
66+
echo "Minikube is already installed!"
67+
else
68+
echo "Installing minikube..."
69+
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.25.2/minikube-linux-amd64
70+
chmod +x minikube
71+
mv minikube /usr/local/bin/
72+
fi
73+
74+
if hash terraform 2>/dev/null; then
75+
echo "Terraform is already installed!"
76+
else
77+
echo "Installing terraform..."
78+
curl -Lo terraform.zip https://releases.hashicorp.com/terraform/0.11.7/terraform_0.11.7_linux_amd64.zip
79+
unzip terraform.zip
80+
mv terraform /usr/local/bin/
81+
rm terraform.zip
82+
fi
83+
84+
if hash helm 2>/dev/null; then
85+
echo "Helm is already installed!"
86+
else
87+
echo "Installing Helm..."
88+
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh
89+
chmod 700 get_helm.sh
90+
./get_helm.sh
91+
rm get_helm.sh
92+
fi

0 commit comments

Comments
 (0)