k8s Getting Started Tutorial

1. k8s Overview

Kubernetes (referred K8S) is Google's open source distributed container management platform to help us manage our container application server in the cluster.

 

Tutorial focuses on how to use Ali cloud container services (kubernetes version).

2. k8s general concepts introduced

  • Node  (Master node and Worker node)
    node generally refers to the server, there are two nodes in k8s in: management node (Master Node) and worker nodes (Worker Node)
    management node (Master Node): responsible for managing the entire k8s cluster, general HA architecture consists of three managed nodes.
    Work node (Worker Node): primarily responsible for running container.

 

  • Namespace  (the Namespace)
    K8S namespaces are used to isolate cluster resources, such as container isolation, provides a virtual isolation strategy for cluster; there are three default namespace, which are the default namespace default, the system namespace kube-system and kube-public.

 

  • Object
    K8S objects (Object) is a persistent storage and for an entity representing a cluster state. k8s the object is actually k8s own configuration protocol, in short, we can define an object by object defined according to let k8s perform some tasks deployment, monitoring tasks and so on.

 

  • POD
    Pod is Kubernetes smallest basic unit to deploy applications or services. Pod package a multiple application containers (there may be only a container), storage resources, an independent IP network management and control vessel operating mode of policy options.

 

  • Replica set  (Replica Set, RS)
    is a controller, responsible for monitoring and maintaining the cluster pod copies (replicas) number, to ensure that the number of copies pod is the way we expect.

 

  • Deployment  (Deployment)
    expressed an update k8s cluster, the cluster is the most commonly used k8s Object, mainly for the deployment of applications. Support rolling upgrades.

 

  • Service  (-Service)
    is applied to the abstract, the basic operation is k8s unit, a plurality of service behind a pod supported by the load balancing policy service forwards the request to the vessel.

 

  • Ingress
    is a gateway service, k8s service can be exposed to the outside through the http protocol.

 

  • Stateless Applications & stateful application
    • Stateless application refers to an application running in the container when not persistent data stored in a container, the container application can freely create, destroy; if there are a plurality of application instances containers, for stateless applications, forward the request to any of a container examples can be run properly. For example: web application
    • Stateful application refers to an application running in a container when required persistent storage stable, stable network identifier, pod fixed start and stop sequence. For example: mysql database

3. k8s architecture

The figure can be seen by k8s overall architecture consists of worker master node on the left and right of the composition, master node is responsible for the entire cluster management, the right of the computer represents a container worker nodes are responsible for running our deployment.

4. Based on k8s of common web application deployment architecture


From top to bottom, as the http request Ingress inlet for receiving a client request, Ingress forwarding to the corresponding service request according to routing rules, and then forwarded to the service instance corresponding to the container according to the load balancing policy request, the cloud service of all underlying container examples of sharing.

5. Deploy Application

The following is a visual way to deploy applications by Ali cloud container service background.

Ali cloud deployment application connectivity.

https://help.aliyun.com/document_detail/87784.html?spm=a2c4g.11186623.6.631.6ca67d26RVHzA4

6 between the shared file storage vessel

In a clustered environment, in default if the application creates a file container A, container B can not read the file.

In k8s provided in a persistent volumes (Persistent Volumes) to solve persistent storage problems, persistent storage volumes and store data access details of the separation, the use of data for users with a unified interface to access different storage systems.

Depending on the storage, support for multiple k8s lasting volume (Persistent Volumes) type, Ali cloud also k8s some extended support, currently supports NAS, OSS, the three durable cloud disk volume type.

Here is the introduction to Ali cloud support lasting volume type:

  • NAS - Ali cloud high-performance distributed file system that supports shared storage.
  • OSS - Ali cloud object storage, is a distributed file system that supports shared storage.
  • Cloud disk - Ali disk and so on, does not support shared memory.

 

According to the above description we can choose OSS NAS or file sharing data, OSS mainly for pictures, video files stored scene can support direct foreign access to services provided in the container file sharing data, we generally choose NAS, NAS use of the following is K8S tutorial:

https://help.aliyun.com/document_detail/88940.html?spm=a2c4g.11186623.6.680.18656b80CZtc9r

 

Cloud on the disk, a plurality of containers can not be shared, each disc POD own exclusive examples cloud is suitable for applications deployed state persistent store, such as deployment mysql, save the data to the cloud mysql disk.

 

Tip: Regardless of what type of persistent volumes are ultimately mounted in a manner associated with the container. The user is concerned, eventually we see is a directory.

7. k8s Configuration Management

If a desired image (image) is more universal, independent of environment, it should be environment-related configuration parameters separated from the mirror.

for example:

   We code a web application packaged into a mirror, if the web application on the database connection address, account numbers, passwords are packaged together into a mirror, then this image if we want to change a database configuration information for how to do? It can only be re-packaged mirror.

 

k8s offers two configuration management for our way: configMap and secret.

They are in the form of key-value pairs, the difference is dedicated to managing secret grateful configuration information, such as: password.

 

Whichever manage configuration, the final configuration information is to be injected into the container.

There are two ways the configuration information is injected into the vessel: the environment variables and mount (Mount) data volume

  • Injected into the vessel by way of the environment variable, the program as long as the container can obtain configuration information by reading the value of the environment variable.
  • By way of mount data volume injected, are generally mounted to a directory, the directory data is read as long as the configuration information can be acquired.

 

Here is Ali cloud using the configuration examples:

 

First, create a configuration item:

 

 

Next, the configuration is injected into the vessel by injection look environment variables:

New applications in the background or Ali cloud editing application, the following window will appear

 

 

The following configuration information is injected into the mount by:

Also in the editing application or a new application window, set data volume.

 

 

 

Ali cloud background operation connection details:

https://help.aliyun.com/document_detail/86769.html?spm=a2c4g.11186623.6.671.667f142e1EUHo4

 

Guess you like

Origin www.cnblogs.com/lyc94620/p/10945505.html