Skip to content

Instantly share code, notes, and snippets.

@leaderdevops
Forked from DylenTurnbull/RancherNGINXDemo.md
Created June 20, 2022 08:57
Show Gist options
  • Save leaderdevops/49537ee9bf39f7fff1df1f50b246612c to your computer and use it in GitHub Desktop.
Save leaderdevops/49537ee9bf39f7fff1df1f50b246612c to your computer and use it in GitHub Desktop.

Rancher & NGINX Ingress Controller - Demo

Demo Prep

To prep for the demo environment begin by logging into the "dev" system using the Console (Access > Console)

  • Open the Firefox browser
  • Click on the link for the Rancher manager if it does not pop up as the default site.
  • Log in using the username and password from the Documentation tab in UDF, this should be pre-populated.
  • Open a Visual Studio Code (VSCode) instance

Open a series of terminal windows using Visual Studio Code (VSCode). From the right set of controls, you should have five terminal sessions total as seen below.

  • Session 1 main command window
  • Session 2 SSH as root into k8s-02-cp-01 node (10.1.1.12)
    ssh [email protected]
    
  • Session 3 SSH as root into k8s-02-wk-01 node (10.1.1.13)
    ssh [email protected]
    
  • Session 4 SSH as root into k8s-02-wk-02 node (10.1.1.14)
    ssh [email protected]
    
  • Session 5 Run the watch command below to monitor the cluster. (Optional - Note this will not work until the cluster is running)
    watch kubectl get pods --all-namespaces
    

Install RKE2 without the default ingress controller

In the browser window for rancher click the hamburger menu in the upper left corner.

Select cluster management

Select the create button

Locate cluster type toggle and ensure that the cluster type is set to RKE2/k3s

Click the "Custom" option at the bottom of the page

Give the cluster a name like "rke2-cluster1"

Set the container network to canal

From "System Services" options ensure that the "NGINX Ingress" option is NOT selected

Click the "Create" button at the bottom of the page

In "Step One" leave all the checkboxes checked

Ensure that the "insecure" option is checked

Click the curl command box and you should see a notification that the command has been copied

Change windows to VSCode and ensure that the second terminal session, currently logged into the 10.1.1.12 node, is selected. then run the netplan apply command below for good measure.

netplan apply

Paste in the copied curl command and hit enter.

Return to the Firefox browser window with the Rancher Manager and watch the status bar until the first node finishes provisioning. This should take 3 - 5 minutes.

Once the control plane node has finished provisioning, return to step one and deselect etcd and control plane. Leave worker selected.

Scroll down to step two and ensure that the insecure option remains checked

Execute the following steps

  • Click the curl command box again and look for the copied notification.
  • Return to VSCode and ensure that the third terminal session, connected to node two on ip address 10.1.1.13 is selected.
  • Run the netplan apply command as above then paste in the curl command.
  • Repeat the last two steps in the terminal session attached to node three on ip address 10.1.1.14.
  • Return to the Rancher Manager in the browser this should still be on step 2 from the tasks above.
  • Select the "Machines" option / tab center screen, to display all machines in this cluster.

Once finished provisioning you should see the tag "Running" on all three systems and the title section should have the tag "Active" displayed as green. The cluster is now provisioned.

Return to VSCode and select the top terminal session that is connected to the dev system and run the following command to copy over the config file

scp [email protected]:/etc/rancher/rke2/rke2.yaml /home/ubuntu/.kube/config

Edit the config file using VI to add the IP address as pictured below

sudo vi /home/ubuntu/.kube/config

Execute the following steps

  • Run the vi command above
  • In the config file use the arrow keys to navigate to the location pictured
  • Use the "i" key on your keyboard to switch to insert mode in VIM
  • Backspace to remove the current loopback IP
  • Type in the IP for your Control Plane node as pictured above.
  • To exit VI and save hit the Esc key then "shift+:" on your keyboard and type "wq" then hit enter Note: This will write the changes out to the config file.

To test that this worked use the kubectl command below to get the cluster nodes.

kubectl get nodes


Deploy an external load balancer in the RKE 2 cluster

To deploy the load balancer use the following commands in the first VScode terminal session.

kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/namespace.yaml
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/metallb.yaml

Change into the demo directory to access the config.yaml for the load balancer

cd /home/ubuntu/demos/rancher/

Apply the config file for the load balancer

kubectl apply -f config.yaml

The process should appear as seen below.

NGINX Ingress Controller Installation

Return to the Rancher Manager browser window and click the menu rollout

Select the cluster named "rke2-cluster1"

Select the "Apps & Marketplace" option from the next screen

Click into the text field and type in "NGINX" into the search field

Select "NGINX Ingress Controller" option.

Select the install button from the following page

To run a default install, select the next button in the following screen. Leaving all values set to default

Leave all options set to default values, click the "Install" button

This should take a few moments. The following will be displayed in the text box pop up.

Close the text box by clicking the "x" button.

The ingress controller should show as "Deployed" in green text.

Show the ingress controller deployed properly by returning to the first terminal session in VSCode. Run the following command that displays NGINX running with an external IP assigned.

kubectl get all -n default

The cluster has been deployed without the default community ingress and the OSS NGINX Ingress Controller has been installed. The demo is complete!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment