k8's documentation

 Installing the Kubernetes CLI kubectl

• Download the latest release v1.15.0
• Or if you have curl installed, use this command:
• curl-LOhttps://storage.googleapis.com/kubernetes-release/release/v1.15.0/bin/windows/amd64/kubectl.exe
• To find out the latest stable version (for example, for scripting), take a look at https://storage.googleapis.com/kubernetes-release/release/stable.txt.
• Add the binary in to your PATH.
• Test to ensure the version of kubectl is the same as downloaded

 Pre-requisites:
You already have a Google Account and have access to Google Cloud Console (https://console.cloud.google.com)

• Step 1: Create a Google Cloud Project OR select and existing Project
In this example I am going to create a new project, however you can select and existing project as far as you have a valid billing account available.
• Once the project is created your Google Cloud Console Home page should look something similar to this
• After Creating the new Project — Home Dashboard

• Step 2: Create a Kubernetes Cluster
Now that you have a project created, you can head to creating a Cluster of your choice. To do this select Kubernetes Engine menu item from the left side navigation. It make take a minute or two to setup the Kubernetes Engine for the first time. The following screenshot depicts the home screen for Kubernetes Engine.

• Select Create Cluster to create your first Kubernetes Cluster.

  Adding Cluster Info
 After one to two minutes you should see your cluster is created and ready to use.

Your Cluster is now Ready to Use

• Step 3: Deploy an App in your Cluster

• Step 4: Clean Up

Once you have deployed an app in the cluster and played a bit with the Cluster you can delete the cluster as simple as selecting the select button on the cluster screen.
Also if you are not going to be using the project again, it is also good practice to delete the project too. You can do this by going to the project setting and selecting SHUT DOWN.

• Install Minikube via direct download

If you’re not installing via a package, you can download a stand-alone binary and use that.
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
&& chmod +x minikube
Here’s an easy way to add the Minikube executable to your path:
sudo install minikube /usr/local/bin

Using Kubernetes for local development

• detect changes in the source code and automatically build, push and deploy.
• automatically update image tags, so you don’t have to do that manually in the Kubernetes manifest files.
• build/deploy/push different applications at once, so it is a perfect fit for microservices too.
• How to start Minikube dashboard?
• Click Launch Terminal. Launch Terminal. …
• Open the Kubernetes dashboard in a browser: …
• Katacoda environment only: At the top of the terminal pane, click the plus sign, and then click Select port to view on Host 1.
• Katacoda environment only: Type 30000 , and then click Display Port.

Understanding The Structure Of A Kubernetes Manifest file
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80

• replicas – Tells Kubernetes how many pods to create during a deployment. Modifying this field is an easy way to scale a containerized application.
• spec.strategy.type – Suppose there is another version of the application that needs to be deployed, and during the deployment phase, we need to update without facilitating an outage. The Rolling Update strategy allows Kubernetes to update a service without facilitating an outage by proceeding to update pods one at a time.
• spec.strategy.rollingUpdate.maxUnavailable – The maximum number of pods that can be unavailable during the Rolling update.
• spec.strategy.rollingUpdate.maxSurge – The maximum number of pods that can be scheduled above the desired number of pods.
• spec.minReadySeconds – An optional Integer that describes the minimum number of seconds, for which a new pod should be ready without any of its containers crashing for it to be considered available.
• spec.revisionHistoryLimit – An optional integer attribute that you can use to tell Kuberneres explicitly how many old ReplicaSets to retain at any given time.
• spec.template.metadata.labels – Adds labels to a deployment specification.
• spec.selector – An optional object that tells the Kubernetes deployment controller to only target pods that match the specified labels. Thus, to only target pods with the labels “app” and “deployer” we can make the following modification to our deployment yaml.
• Debugging Pods
If the command “COMMAND” is expected to run in a Pod and produce “OUTPUT”:
u@pod$ COMMAND
OUTPUT
If the command “COMMAND” is expected to run on a Node and produce “OUTPUT”:
u@node$ COMMAND
OUTPUT
If the command is “kubectl ARGS”:
kubectl ARGS
OUTPUT

• Creating Objects From File Manifests

  1. You should leave space between the name and value of any section in manifest file, like Version:1.1 is in valid section instead write Version: 1.1 that space between colon and 1.1 really matters a lot.
  2. While specifying the main class you should not add .class extension at the end of class name. Simply specify the main class by typing:
    Main-Class: Classname
    (I’ll be briefing about Main-Class section very shortly).
  3. You must add newline at the end of file. You need not to write \n for specifying newline instead just leave the last line of your manifest file blank that will serve the purpose.
  4. Text file for manifest must use UTF-8 encoding otherwise you may get into some trouble.

• Creating A Deployment Using kubectl run
• You can create and manage a Deployment by using the Kubernetes command line interface, Kubectl. Kubectl uses the Kubernetes API to interact with the cluster. In this module, you’ll learn the most common Kubectl commands needed to create Deployments that run your applications on a Kubernetes cluster.
• When you create a Deployment, you’ll need to specify the container image for your application and the number of replicas that you want to run. You can change that information later by updating your Deployment; Modules 5 and 6 of the bootcamp discuss how you can scale and update your Deployments.
Applications need to be packaged into one of the supported container formats in order to be deployed on Kubernetes
For your first Deployment, you’ll use a Node.js application packaged in a Docker container.

• Enabling Autocomplete For kubectl
• $kubectl completion -h