Cloud native actual combat is one of the cloud native courses jointly created by Shang Silicon Valley and KubeSphere
Course link:
The first lesson of cloud native Java Architect: K8s+Docker+KubeSphere+DevOps_ Beep beep beep_ bilibili
Learning materials:
k8s official website: Kubernetes documentation | kubernetes
Cloud native actual combat · YuQue (yuque.com)
Learning content:
Cloud platform core Docker Basics Kubernetes Introduction to actual combat KubeSphere Platform installation KubeSphere Visualization platform KubeSphere actual combat Cloud primordial DevOps Foundation and actual combat Micro service foundation and Practice
1. Cloud platform core
1. Why cloud platform
-
Environmental unity
-
Pay on demand
-
Ready to use
-
Strong stability
-
...
Common domestic cloud platforms:
- Alibaba cloud, baidu cloud, Tencent cloud, huaweiyun, Qingyun
Common cloud platforms abroad:
- Amazon AWS, Microsoft Azure
2. Gong Youyun
Purchase public servers provided by cloud service providers
Public cloud is the most common type of cloud computing deployment. Public cloud resources (such as servers and storage space) are owned and operated by third-party cloud service providers, and these resources are provided through the Internet. In the public cloud, all hardware, software and other supporting infrastructure are owned and managed by the cloud provider. Microsoft Azure is an example of a public cloud.
In the public cloud, you share the same hardware, storage and network devices with other organizations or cloud "tenants", and you can use a Web browser to access services and manage accounts. Public cloud deployment is usually used to provide Web-based e-mail, online office applications, storage, and test and development environments.
Advantages of public cloud:
-
Lower cost: no need to buy hardware or software, only pay for the services used.
-
No maintenance required: maintenance is provided by the service provider.
-
Almost unlimited scalability: provide on-demand resources to meet business needs.
-
High reliability: it has many servers to ensure that it is free from faults.
-
Availability: annual failure time: 365 * 24 * 3600 * (1-99.9999%)
3. Private cloud
Build your own cloud platform, or buy it
The private cloud is composed of cloud computing resources dedicated to an enterprise or organization. The private cloud can be physically located in the organization's field data center or hosted by a third-party service provider. However, in the private cloud, services and infrastructure are always maintained on the private network, and hardware and software are exclusively used by the organization.
In this way, private cloud can make IT easier for organizations to customize resources to meet specific IT needs. Private cloud is usually used by government agencies, financial institutions and other medium-sized to large organizations that have business critical operations and want to have greater control over the environment.
Advantages of private cloud:
-
More flexibility: organizations can customize the cloud environment to meet specific business needs.
-
Stronger control: resources are not shared with other organizations, so they can obtain higher control and higher privacy level.
-
More scalable: private clouds are generally more scalable than local infrastructure.
No cloud computing type works for everyone. A variety of different cloud computing models, types and services have been developed to meet the rapidly changing technical needs of organizations.
There are three different ways to deploy cloud computing resources: public cloud, private cloud and hybrid cloud. The deployment method adopted depends on business requirements.
2. Core framework
Required software
electerm: https://electerm.github.io/electerm/
https://wwa.lanzoui.com/b016k9bha
Password: 900h
xshell
Register cloud platform:
-
Alibaba cloud aliyun.com
-
Tencent cloud cloud.tencent.com
-
Hua Weiyun cloud.huawei.com
Qingyun qingcloud.com
Baidu cloud cloud.baidu.com
...
1. Basic concepts
-
Cloud server as the final carrier of application
-
VPC provides network isolation for all ECs
-
All ECs are bound to a private network
-
Security control rules for each firewall group
-
Public IP makes resources accessible
-
Access to specific servers through port forwarding
3. Basic concepts of docker
3.1 problems solved
1. Unified standard
-
Application construction
-
- Java,C++,JavaScript
- Package
-
- .exe
- docker build... Image
-
Application sharing
-
- All software images are placed in a designated place docker hub
- Android, application market
-
Application running
-
- Unified standard image
- docker run
-
...
2. Resource isolation
-
Isolation and limitation of cpu and memory resources
-
Access device isolation and restriction
-
Network isolation and restriction
-
User and user group isolation restrictions
-
...
3.2 architecture
-
Docker_Host:
-
- Host where Docker is installed
-
Docker Daemon:
-
- Docker daemon running on docker host
-
Client:
-
- Client for operating Docker host (command line, UI, etc.)
-
Registry:
-
- Mirror warehouse
- Docker Hub
-
Images:
-
- Image, a packaged program with environment, can be started and run directly
-
Containers:
-
- Container, a running program started by the image
Interactive logic
Install Docker, then go to the software market to find the image, download and run it, check the container status log and troubleshoot
4. Docker command actual combat
4.1 common command diagram
Practical basis
1. Find image
$ docker pull nginx #Download the latest version Image name:Version name (label) $ docker pull nginx:1.20.1 $ docker pull redis #Download the latest $ docker pull redis:6.2.4 ## The downloaded images are all local $ docker images #View all mirrors redis = redis:latest # remove $ docker rmi Image name:Version number/image id
2. Start container
Start the nginx application container and map port 88 to test the access
docker run [OPTIONS] IMAGE [COMMAND] [ARG...] [docker run Setting item [image name] the command to start and run the image (there is one in the image by default, and it is generally not written) # -d: Background operation # --restart=always: start automatically docker run --name=mynginx -d --restart=always -p 88:80 nginx # View running containers docker ps # View all docker ps -a # Delete stopped containers docker rm container id/name docker rm -f mynginx #Force deletion of running #Stop container docker stop container id/name #Restart docker start container id/name #Application startup and self startup docker update container id/name --restart=always
3. Modify container contents
Modify the default index HTML page
(1) Modify inside the container
# Enter the system inside the container and modify the contents of the container docker exec -it container id /bin/bash
(2) Mount data (- v) to external modification
docker run --name=mynginx \ -d --restart=always \ -p 88:80 -v /data/html:/usr/share/nginx/html:ro \ nginx # To modify the page, you only need to go to / data/html of the host
4. Submit changes
Submit your modified image
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] docker commit -a "leifengyang" -m "Home page change" 341d81f7504f guignginx:v1.0
(1) Image transfer (offline installation)
# Save the image as a compressed package docker save -o abc.tar guignginx:v1.0 # Another machine loads this image docker load -i abc.tar
5. Push remote warehouse
Push the image to the docker hub; Application market
docker tag local-image:tagname new-repo:tagname docker push new-repo:tagname
# Change the name of the old image to the new name required by the warehouse docker tag guignginx:v1.0 leifengyang/guignginx:v1.0 # Log in to docker hub docker login docker logout((exit after image pushing) # Push docker push leifengyang/guignginx:v1.0 # Download from other machines docker pull leifengyang/guignginx:v1.0
6. Supplement
docker logs Container name/id Troubleshooting docker exec -it container id /bin/bash # docker often modifies nginx configuration files docker run -d -p 80:80 \ -v /data/html:/usr/share/nginx/html:ro \ -v /data/conf/nginx.conf:/etc/nginx/nginx.conf \ --name mynginx-02 \ nginx #Copy what is in the designated position of the container docker cp 5eff66eec7e1:/etc/nginx/nginx.conf /data/conf/nginx.conf #Copy the outside contents into the container docker cp /data/conf/nginx.conf 5eff66eec7e1:/etc/nginx/nginx.conf