原文地址:OpenStack, Docker以及Kubernetes的搭建
Part 1: OpenStack
Step 1
Create a new Virtual Machine named as "StudentName-OS" and your VM should be placed in 'Lab Final Exam' folder. Deploy the machine according to the below configs.
OpenStack controller node:
- 2 Dual core CPU
- 4 GB RAM
- 40 GB HDD -
- Network Adapter - Bridge adapter
- CentOS minimal OS - http://mirror.dal.nexril.net/centos/7.9.2009/isos/x86_64/ or Centos 8 Stream.
Also, while spinning up VM, choose "Minimal Install"
During CentOS installation, set root password as 'Dcne123'. Perform entire OpenStack Part of final lab with 'root' user.
Step 2
Get the remote console of your VM using Putty and note down the IP addresses of interface ens192.
Note: Convert your DHCP leased IP on the interface to static IP by configuring the interface configuration in CentOS. Interfaces should start on boot.
Step 3
Set your node's hostname to "initials_of_firstname_&_lastname-OS"
Once you have successfully configured static IP and hostname on controller, reboot the system to activate the changes. Your node should reflect its new hostnames and should have the same IP address which you configured. If not, you may have configured it incorrectly. Resolve the issues, verify and proceed. (Attach snapshots of both the files)
Step 4
Verify Internet connectivity.
If you are unable to get access to internet, verify your configuration and check DNS configuration as well.
Step 5
Enable OpenStack repositories and network-scripts that will be required to install OpenStack packages on a CentOS 8 server.
Step 6
Before installing openstack, make sure to disable the firewall and NetworkManager and Firewall.
Step 7
Add OpenStack Ussuri Repository
Firstly, check what all centos-release-openstack packages are available. Then install Ussuri release repository package.
Once installed, then update all current OS system packages.
Reboot the system after the upgrade is complete.
Step 8
Installing Packstack Installer
Once the system is available after the reboot, install Packstack utility.
Step 9
Generate answer file and edit it
Now, before installing the components, edit "answers" file to set a custom keystone admin password.
Open this file using any editor and make following changes.
Changes:
CONFIG_HEAT_INSTALL=y
CONFIG_PROVISION_DEMO=n
CONFIG_KEYSTONE_ADMIN_PW=Dcne123
CONFIG_NEUTRON_OVN_BRIDGE_IFACES=br-ex:ens192
CONFIG_NEUTRON_ML2_TYPE_DRIVERS=geneve,flat
CONFIG_NEUTRON_ML2_TENANT_NETWORK_TYPES=geneve
Save and exit the file.
Step 10
Run Packstack to Install OpenStack using the configured 'answers.txt' file
Run the following command to initiate the OpenStack Deployment using answer file.
Command:
# packstack --answer-file /root/answers.txt
Deployment will take around 20 to 30 minutes.
Step 11
Now verify whether IP from ens192 interface is assigned to bridge br-ex, also confirm whether interface ens192 is added as a port in ovs-bridge.
Make note of the file path /root/keystonerc_admin. To perform OpenStack operations, we will source this file. This is our user credentials file.
Step 12
Access Horizon Dashboard
Now try to login to Horizon dashboard. URL is already specified in the above output, in my case URL is http://129.119.125.108/dashboard
Use the username as "admin" and password as "Dcne123" that we specified in answer file.
Step 13
Before launching an instance in OpenStack, lets source admin credentials
Commands:
# source keystonerc_admin
Step 14
Now we will create public and private network and then add a router.
- A. Create private network in admin tenant and add a subnet to it.
- B. Create Public network and add a subnet to it.
- C. Create a router, it will connect public and private subnets, set its gateway as pub_network and link pvt_network as well.
Step 15
Now Download Cirros image and then upload it to glance.
Step 16
Also, we will add a security group named "secure" and SSH, ICMP rules to it.
Step 17
Create Private keypair for SSH.
Step 18
Create an instance now and verify it.
Step 19
Now you have to go to Dashboard and verify instance from there.
Once OpenStack Part is completed, Delete the VM, Use: Delete from Disk option
Part 2: Linux
- Create a new VM as "your name- Final lab Linux". Get the IP address of the VM and access the machine using Putty.
- Change Hostname of VM to "initials_of_firstname_&_lastname-Linux". Add a user named "dcne", set password as "Dcne123", add it to root group, reboot machine and login with new user credentials. Perform entire Part 2 of final lab with newly created user.
- Create a file called file.txt and paste the following.
- Which command will you use to print the first 3 lines of 'file.txt'? How will you print the last 4 lines? Remove line #5 and line #8 without even opening the file.
- Create the following directories in new users home directory. Create File1.txt in Folder_1AA, File2.txt in Folder_1ABA, File3.txt in Folder_2A and File4.txt in Folder_2. (Complete the above task using shortcuts).
- Edit File1.txt we created in Folder_1AA and paste content - "This data is from File1". Create a symbolic link in new user's home directory to File1.txt in Folder_1AA and name it as 'sym_link'. Read the contents of 'sym_link'. If we edit the symbolic link file, will it also change the original file? Try it and show the output.
Create two files 'DCNE1', 'DCNE2', and assign following permissions:
- DCNE1 - Give r/w/x permissions to owner, r/w to group and others
- DCNE2 - Give r/w/x to others, r/w to group and r to owner
- Create a file named 'Grep.txt' in your home directory and paste the following contents of the text file attached. (Use the grep file which you all used in your earlier lab)
- How would you use a content of one file as a search string for another file? Create a file named 'data.txt' containing the word "data" (which will be your search string) and use it to search word 'data' in 'Grep.txt' file.
- Piping 2 or more commands.
Execute: 'grep dcne /etc/passwd' and then cut the data from column 1,4,7 and show the output in screenshot. - Add a 1 GB partition in the system. After adding new partition, format it. And then mount it permanently using UUID to '/finals' directory. Don't forget to verify it after reboot. (Show proof of entire operation)
- Copy data from "/usr/bin" and paste it to a new directory named "/comp", check size of "/comp". Then perform compression on it and save it in a file named as "your-name" with correct extension. Also check the size of an archived file.
Once Linux Part is completed, Delete the VM, Use: Delete from Disk option
Part 3: VMware
- What are Port Groups, VMkernel NICs and Physical NICs in ESXi host?
- What is vMotion?
- Explain what is the difference between Cold Migration and Live Migration?
- What is VMware Fault Tolerance?
- What is VMware HA?
- What is VMware DRS?
Part 4: Ansible
Create a new VM from ubuntu image (use the images as used earlier in labs) Name the VM as "yourname-Ansible". Power on the VM. Open terminal and login to VM with User ID: "student" and use password as "Dcne123"
- Launch a Linux container using 'ubuntu 18.04' image and name it as '
-finals'. Login to the shell and then update and upgrade your container, install 'nginx'. Then edit the default index file inside container, located at '/var/www/html/index.nginx-debian.html'. Make following changes to file. - Restart nginx server and find containers IP address. Then verify webpage you just created by accessing the URL from web browser. (Use your container's IP)
- Exit from container's shell and take snapshot of your container and name it as '
-finals-1.0'. - Create 3 more containers using the same ubuntu image and name them as Application1, Application2 and Database. Perform necessary steps in order to ansible-playbook and ansible-adHoc commands work smoothly on all 3 containers.
- Edit the default inventory file (/etc/ansible/hosts) of Ansible and add Application1, Application2 container's IP in a group called 'application' and Database containers IP address to a group called 'database'. Also, add their IPs in the default group 'webservers'.
- Once done, use ansible ad-hoc ping command to ping webservers, application and database separately. You should get success messages.
- RUN Ansible ad-hoc command on 'application' group which creates user named 'mustang' having primary group as root, password as 'Dcne123', home directory as '/home/mustang', shell as '/bin/bash' and User id (uid) as 1007.
- RUN Ansible ad-hoc command on 'database' which installs 'nginx' and starts its service.
- Create a Playbook named 'one.yml' to install nmap, apache2 on 'application1' and 'application2' containers. It should also install 'postgresql' on database container. Paste screenshots of playbook, command and output after running playbook.
- Create a playbook named 'two.yml' to add three users Sam, Joe, Michelle to 'application' group. Use Ansible Loops in this playbook. Run this playbook on both containers from application group in such a way that Playbook will not get executed on both of them at same time, it should run on 2 containers in one after another manner (Use Parallelism in Ansible). Paste screenshots of playbook, various commands used here and their outputs.
- Create a playbook named 'three.yml' to compress data from database containers '/usr/bin' directory into 'student' users (from Ansible host) home directory. Playbook must have Ansible variables for compression format, compression source path and compression file destination defined in separate 'variable' file. Paste screenshots of playbook, command used to run it and its output after running the playbook.
Once Ansible Part is completed, Delete the VM, Use: Delete from Disk option
Part 5: Docker Containers
- Create a new VM with base image of Ubuntu Get the IP address of the VM and access the machine using Putty. Perform entire Part 5 of final lab with 'student' user only. Change Hostname of VM to "initials_of_firstname_&_lastname-Docker".
- Run a "nginx" container and make sure it is in running state all the time.
- Deploy a "ubuntu" container with a shell session attached it. Update your container and then do a SSH to your docker host (Ubuntu Desktop Machine) and check the list of all containers present there.
- In your 'student' users home directory create a folder named "SMU" and navigate to it and create 2 blank files named - Dcnelab1 and Dcnelab2. Then create a "Dockerfile" with following specifications.
- Run a container using an image you created in step #4. Now check contents of "/opt/source-code/" directory of container you created in last step. Do this without getting inside the container.
- Get back to 'student' users home directory and launch a container based on 'centos' image with an interactive terminal attached to it. Once inside the container's shell, install following packages.
While creating this container perform necessary steps so that you can access it through internet. Once everything is installed, start the 'httpd' service and verify the web page from any browser present on your Windows Laptop or MacBook. - Create a new network named"your-name"using thebridgedriver. Allocate subnet 182.28.0.0/24. ConfigureGateway 182.28.0.1. Verify bridge network you created.
- Run 2 container using 'centos' image. Attach them to above created 'bridge' network and try to ping one another.
- Create a (shared) Docker Volume named "Shared-Volume" and attach it to a new container named 'Shared1'. Use "centos" image to create it. "Shared1" will store all the data from "/root/student/shared1" directory to "Shared-Volume". Once you launch the container, get inside the "/root/student/shared1" directory and create a file named "SMU" which should contain - "SMU MustangsPony Up!".
- Create a new container named 'Shared2' and attach this container to "Shared-Volume". Again, use a "centos" image. "Shared2" will store all the data from "/root/student/shared2" directory to "Shared-Volume". Once you launched the container, get inside the "/root/student/shared2" directory and check if you can see the file created by "Shared1"? If yes, paste the output.
Once Docker Containers Part is completed, Delete the VM, Use: Delete from Disk option
Part 6: Kubernetes
Refer Kubernetes Cluster Setup file attached in Canvas to build K8s cluster. (Another file in Lab exam final)
- Create Pod using YAML file that runs the 'httpd' web server and verify its operation.
- Create a 'mariadb' replicaset and name it as 'mariadb-
' and list all the replicasets. Then scale the replicaset to 4. - Check all pods present in replicaset and delete any one of them and verify it again.
- Create a 'mysql' deployment with 2 replicas through YAML file and then verify it.
- Create a new namespace named 'yourname' through YAML file, then create a new 'redis' Pod inside newly created namespace through YAML file.
- Delete all the objects (from all namespaces) you created in cluster till now.
- Create a 'httpd' Deployment with 2 replicas, use selectors - app=httpd and then create a new service named '
-service' to access the 'httpd' application using the YAML file. Type: NodePort; targetPort: 80; port: 80; nodePort: 30080; selector: app=httpd. Access service created. For that use the IP address of any node followed by the NodePort number. - Now, create a busybox pod using correct image. This will help to query the DNS.
- Perform a DNS query of the httpd service and record/observe the DNS name format.
- Create a pod named "nginx-manual-
". Check which node is the pod scheduled on. Then delete it. - Make the necessary changes to the pod YAML file created above to schedule the pod on different node (Master Node) as we have only 1 worker node.
Once Kubernetes Part is completed, delete both the VMs, Use: Delete from Disk option
(本文出自csprojectedu.com,转载请注明出处)