Rancher Rodeo Demo
Contents
Part I – Create Your Cluster ... 3
Step 01 – Add Cluster ... 3
Step 02 – Add Node Template ... 4
Step 03 – Create Cluster ... 4
Part II – Creating a Deployment, Service, and Ingress with kubectl and YAML Files... 7
Step 01 – Launch kubectl ... 7
Step 02 – Create YAML Files ... 7
Step 03 – Create Deployment ... 9
Step 04 – Create a Service with YAML ... 9
Step 05 – Create an Ingress ... 10
Step 06 – Change Deployment ... 11
Step 07 – Edit Service ... 13
Step 08 – Rollout Deployment then Scale Up! ... 13
Step 09 – Clean Up ... 14
Part III – Creating a Deployment, Service, and Ingress from the Rancher Dashboard ... 15
Step 01 – Select the Default Workload ... 15
Step 02 – Create Deployment ... 15
Step 03 – Create an Ingress ... 16
Step 04 – Change Deployment ... 17
Step 05 – Edit the Ingress... 18
Step 06 – Scale Up (then up or down as you’d like!) ... 19
Login - How and Where
Rancher Console: console.rancher-demo.expedient.comUsername and Password: We’ll send you this separately
Part 0.5 – Night Mode!
Want to change your Rancher Dashboard to a glorious dark mode UI? Hover over your user profile icon* in the top right then go to Preferences *Rancher picks a random, simple image that will look one of these:
You can change your theme from here…
Part I – Create Your Cluster
Step 01 – Add Cluster
From the top right corner, select Add Cluster
Choose Expedient from the Infrastructure Provide list
Choose a name for your cluster
*Whatever you’d like, but please include use your company’s name
Enter your company name for the Name Prefix and check the etcd, Control Plane, and Worker boxes. Leave everything else default.
*This can be the same name as your cluster
etcd (pronounced “etsy-d”) is a key-value store and the primary datastore of Kubernetes. It stores
configuration, specifications, and the status of the running workloads.
The Control Plane is a group of components that manages worker Nodes and Pods in a cluster. A Worker Node is used to runs Pods, the base unit of computing in Kubernetes.
Step 02 – Add Node Template Click Add Node Template
Enter the following into each field…
EXPEDIENT OPTIONS *All fields are CASE SENSITIVE
catalog cpu
k8s-templates 4
memoryMb network
8192 companyname-network
organization password
VMWare-Demo-ACM (We’ll give you this)
region storageProfile
east vCD-Storage-Policy-ACM
template username
k8s-template (We’ll give you this)
vdc
VMWare-Demo_ACM
*For network, use the company name from the URL we provided you companyname.rancher-demo.expedient will be companyname-network Step 03 – Create Cluster
Name your template whatever you’d like, then click Create
This process will likely take between 10 and 20 minutes but for more info formation, click number in the Nodes category
You can see the status of your server as it deploys in Enterprise Cloud and contacts Kubernetes.
Once complete, you can find your cluster in the Cluster menu (top left), and see it now Active
Victory!
*Note: Your preset companyname-network will build your first cluster with a .10 IP address. You can spin up multiple clusters, but only the first one will work with the rest of the demo If you need to delete a cluster, make sure you have more than one node. You can add more nodes under the main Cluster tab, select the number in the Node column.
Part II – Creating a Deployment, Service, and Ingress with kubectl and YAML Files
Step 01 – Launch kubectl
Open the Cluster tab and select the Cluster you created in Part I.
Launch kubectl from the main dashboard:
*Note that kubectl contains the standard GNU toolset you’d fine in a Linux terminal Step 02 – Create YAML Files
For this demonstration, we’re going to create two YAML files. You can copy and paste with the GUI via the right-click menu after using cat to create the files.
Create service.yaml cat > service.yaml
*Spacing is critical to a YAML file and that spacing will be lost when copy/pasting from a PDF. The contents of the file are shown below but you can find a link to a plan text file above each entry.
Copy the text from service.yaml then hit Ctrl+D to save
Link to txt file:
service.yaml
apiVersion: v1 kind: Service metadata: labels: app: nginx name: nginx spec: ports: - port: 80 protocol: TCP targetPort: 80 selector: app: nginx sessionAffinity: None type: ClusterIP Create ingress-single cat > ingress-single.yaml
Copy the text from the link below then hit Ctrl+D to save. You should copy to a text editor first to edit the host, or us vi to do so from the terminal.
Link to text file:
ingress-single.yaml
apiVersion: extensions/v1beta1 kind: Ingress metadata: annotations: nginx.ingress.kubernetes.io/rewrite-target: / name: ingress-single spec: rules: - host: companyname.rancher-demo.expedient.com http: paths: - path: / backend: serviceName: nginx servicePort: 80Step 03 – Create Deployment
Deployments create and update ReplicaSets, allowing you to easily scale and preform rolling upgrades. We’re going to create a deployment for nginx, (pronounced “engine x”), a webserver that can act as a reverse proxy server and load balancer.
Create Deployment
kubectl create deploy nginx --image=nginx:1.14-alpine Check Deployments
kubectl get deploy You’ll see…
Step 04 – Create a Service with YAML
A service defines a DNS entry that can be used to refer to a group of pods. There are 3 types of services: nodePort, clusterIP, and loadbalancer. We’re going to create a clusterIP service.
Let’s take a look at our YAML file. View YAML file service.yaml
cat service.yaml You’ll see…
You can see we’re going to create a clusterIP service on port 80. Go ahead and apply the file. Apply YAML file service.yaml:
kubectl apply -f service.yaml Check Services:
kubectl get service You’ll see…
Step 05 – Create an Ingress
An ingress defines how traffic outside the cluster is routed to inside the cluster, exposing it to the world. You can route traffic to internal services based on factors such as host and path and this is usually implemented by a load balancer like Nginx that we already deployed.
View YAML file ingress-single.yaml cat ingress-single.yaml You’ll see…
The hostname is example.rancherdemo.expedient.com in this guide. Yours will show:
companyname.rancher-demo.expedient.com
Apply YAML file ingress-single:
kubectl apply -f ingress-single.yaml
Go to your web browser and enter the hostname from the YAML file. You should see the “Welcome to nginx!” page.
Step 06 – Change Deployment
Let’s change things up to see some action. We’re going to change the image now. Edit the Deployment:
kubectl edit deploy nginx You’ll see…
Change: containers: - image: nginx:1.14-alpine To: containers: - image: mgaruccio/rancher-demo We’re using the standard vi text editor
1) With the arrow keys, move the cursor to
nginx:1.14-alpine
2) Type i then delete nginx:1.14-alpine3) Paste or type in
mgaruccio/rancher-demo
4) HitCtrl+C
, then type:wq
to save and quit.*Alternatively, if you run into CLI problems using vi, you can accomplish the same task by entering this command:
kubectl delete deployment nginx && kubectl create deploy nginx --image=mgaruccio/rancher-demo
- This deletes the deployment “nginx” then creates a new one with a new image - We’re still calling this “nginx” for consistency throughout the demo
Oh no! Let’s fix that! Step 07 – Edit Service
This application uses port 8080 so we’ll need to change that on the service. Edit the Service
kubectl edit service/nginx You’ll see…
Change port targetPort from 80 to 8080, save and exit.
*Alternatively, if you run into CLI problems using vi, you can accomplish the same task by writing over the service.yaml file with cat
cat > service.yaml
Copy the text from service.yaml into a separate text editor, change the target port from 80 to 8080, then copy paste into your terminal. Hit Ctrl+D to save, then apply the file
kubectl apply -f service.yaml
Step 08 – Rollout Deployment then Scale Up! Rollout Deployment
kubectl rollout status deploy/nginx
We replaced the image and our new deployment is showing us how many copies of our application (replicas) are running. Note that we are no longer running nginx since this is not a new deployment but a change to the existing one.
Hmm, he looks lonely. Let’s add more Cattle! Scale Deployment
kubectl scale deployment nginx --replicas 10
Back in your browser, you can watch the replicas increase from 1 to 10 in real-time!
Hey, that’s a nice-looking herd you have now!
Step 09 – Clean Up
In the next part, we’re going to run through these steps in Ranchers GUI. First, let’s delete our deployment, service, and ingress.
kubectl delete deployment nginx
kubectl delete service nginx
Part III – Creating a Deployment, Service, and Ingress from the Rancher Dashboard
Step 01 – Select the Default WorkloadFrom the Rancher Dashboard, got the Global menu and navigate to your rodeo-demo cluster. Hover over it and then select the Default workload.
Step 02 – Create Deployment Select Deploy near the top right.
Enter the following: Name: nginx
Docker Image: nginx:1.14-alpine
Now Launch! (Bottom Center)
You can see the new workload nginx now as active in the Workloads tab.
Step 03 – Create an Ingress
Rancher will create a service for you automatically, so go to the Load Balancing tab and select Add Ingress from the top right.
Enter the following: Name: ingress-single
Under Rules, select “Specify a hostname”
Request Host: COMPANY.rancherdemo.expedient.com Target: nginx
Port: 80
The ingress will become active:
Check the site you entered for Request Host in your browser example.rancherdemo.expedient.com for this demo
Step 04 – Change Deployment
Go back to the Workloads tab, click the 3-dot menu on the far right, and select Edit
Your workload will automatically update. Go back to your web browser and refresh
The new app uses port 8080 instead of 80. We’ll need to change that.
Step 05 – Edit the Ingress
Under the Load Balancing tab, click the 3-dot menu on the far right, and select Edit
Change the Port from 80 to 8080 and save
Step 06 – Scale Up (then up or down as you’d like!) No, too lonely! Add more cattle!
Go to your Workload tab and hit the plus to scale. Let’s go to 10.
Hit the next to your workload if the scale option isn’t showing. You can also scale in the Edit menu of your workload.
Switch back to your browser and watch the herd roll in!