Google Kubernetes

Objective


Learn how to set up a machine on Google Cloud.


Steps


  1. Create an account on Google Cloud
  2. Create a machine
    1. Specify which image to use and which flavor
    2. Insert your SSH Key
    3. Update Firewall Rules
  3. Connect to the Machine
  4. Download the pre-requisites, the installer & run the Installer pre script on the machine
    1. Copy the Kubernetes Token



Step 1: Create an account on Google Cloud


  • Begin by Creating a Google Cloud account →  Click Here.
    • Follow the steps of Google Cloud wizard



Step 2: Create a machine


  • Click on Compute Engine → VM Instances → Create Instance
  • Specify the machine image type, OS and version:  Ubuntu 16.04 LTS
  • Specify the flavor: 3.75 GB Compute v1
  • Click on: Management, disks, networking, SSH keys
    • Select SSH Keys Tab
    • Paste your public ssh key value
  • Click on VPC Networks → Firewall Rules
    • Enable the ports needed to deploy the Cloud and connect to Mongo and Nginx
Create VM InstanceEnter your SSH KeyFirewall Rules Configuration



Step 3: Connect to the Machine


Once you add your public ssh key, the username shows up next to it in the google wizard. use that username to SSH the machine.

Connect to the Machine
# connect to the machine using the IP address
> ssh %username%@%external ip address of machine%
External IP Address



Step 4: Download the pre-requisites, the installer & run the Installer pre script on Google Machine


Once you SSH to the machine, you can download and run the installer pre installation script to get all the dependencies so that cloud deployment works.

Prepare the machine

Download & Run SOAJS Installer pre scripts
# download update apt-get, npm and zip
> sudo su
> apt-get update && apt-get -y upgrade
> apt-get install npm

# download the latest version of nodejs
> curl -sL https://deb.nodesource.com/setup_6.x | bash && apt-get install -y nodejs
Run the installer
# download installer 
> mkdir -p /opt/soajs/node_modules 
> cd /opt/soajs/node_modules 
> sudo npm install soajs.installer 

# run installer pre script
> cd soajs.installer/scripts/pre 
> sudo /opt/soajs/node_modules/soajs.installer/scripts/pre/kubernetes-linux.sh <%YOUR_CUSTOM_DOMAIN%>

# By default, your cluster will not schedule pods on the master for security reasons.
# If you want to be able to schedule pods on the master, e.g. for a single-machine Kubernetes cluster for development, run
> kubectl taint nodes --all node-role.kubernetes.io/master:NoSchedule-

Grab the kubernetes Secret

Grab the kubernetes secret token by running the below command

Grab the Kubernetes Secret Token
# get kubernetes secrets
> kubectl describe secrets

# output
Name:		default-token-jc5fg
Namespace:	default
Labels:		<none>
Annotations:	kubernetes.io/service-account.name=default
		kubernetes.io/service-account.uid=50edbe21-8288-11e7-b935-bc764e2011e4

Type:	kubernetes.io/service-account-token

Data
====
ca.crt:		1025 bytes
namespace:	7 bytes
token:		eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6ImRlZmF1bHQtdG9rZW4tamM1ZmciLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGVmYXVsdCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjUwZWRiZTIxLTgyODgtMTFlNy1iOTM1LWJjNzY0ZTIwMTFlNCIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDpkZWZhdWx0OmRlZmF1bHQifQ.0FtEvs9YLo9EZkVE9rYewEM6DdD4HWZMeuMBwznFEV6ZEjRSIv-yb21iCRSJTvUiSs1aiOQKl501Z7oVEq3RRbc2E3obR9CuvoUlYbzKTRwTT3ZeSNDJ--2ahlPCpE1WS0S_sfxMnS_eiafdY37wSzydD4baamQxX7ZgFy-kCyKc72ipXamXnH3ev2yxvSIjEuXeCT5XVDOyyghRp5OJAgcIzsKDPkkeDDnrvkSFGMYaW1Rrez7IV0VbwZCTccaQuyjhQbR8-zSMsJboRSud8BZOxrVAGKkiuWStL7isvp83zlqqI7yMj5SDjZiXcvCR4ijH0-j8FbI3e4LQipdb5w