feat: Add services user guide

Signed-off-by: Harrison <harrisonliu_5@163.com>
This commit is contained in:
Harrison 2020-09-29 18:00:45 +08:00
parent d60c7459cf
commit 8e4e9cd567
9 changed files with 77 additions and 164 deletions

View File

@ -1,7 +1,7 @@
---
title: "Services"
keywords: 'kubesphere, kubernetes, docker, jobs'
description: 'Create a Kubernetes Job'
description: 'Create a Kubernetes Service'
weight: 2060
@ -10,41 +10,82 @@ weight: 2060
## What is the Service
An abstract way to expose an application running on a set of Pods as a network service.
With Kubernetes, you don't need to modify your application to use an unfamiliar service discovery mechanism. Kubernetes gives Pods their IP addresses and a single DNS name for a set of Pods, and can load-balance across them.
## Service Type
- **VirtualIP**It is based on the unique IP generated by the cluster. The service inside the cluster can be accessed through this IP, and the service outside the cluster can be accessed through NodePort and LoadBalancer. This type is suitable for most services.
- **Headless**The cluster does not generate an IP for the service, and the service is directly accessed through the back-end Pod IP of the service within the cluster. This type is suitable for back-end heterogeneous services, such as services that need to distinguish between master and slave.
{{< notice tip>}}
In Kubesphere, the **Virtual IP** is a default type of a service that is created by **stateless** or **stateful**.<br />
If you want to create a Headless service, you should use the mode of **YAML**.
{{</ notice>}}
## Prerequisites
- You need to create a workspace, project and `project-regular` account. Please refer to the [Getting Started with Multi-tenant Management](../../../quick-start/create-workspace-and-project) if not yet.
- You need to sign in with `project-admin` account and invite `project-regular` to enter the corresponding project if not yet. Please refer to [Invite Member](../../../quick-start/create-workspace-and-project#task-3-create-a-project).
## How to create a Service
![create_service_type](/images/docs/project-user-guide/workloads/create_service_type.png)
Create a service that has these methods in the Kubesphere: Stateless Service, Stateful Service, and External Service. what's more you can custom creation through **Specify Workloads** and **Edit by YAML**.
Create a service that has these methods in the Kubesphere: **Stateless Service**, **Stateful Service**, and **External Service**. what's more, you can custom creation through **Specify Workloads** and **Edit by YAML**.
*There are some information you should know:*
There are some ways to create a service
- The value of `annotations:kubesphere.io/serviceType` keywords is one of them **statelessservice** , **statefulservice** , **externalservice** and **None**.
- Different types of Service you created could create a different workload that it may be a **Deployment**, **StatefulSet**, or **DaemonSet** at moment.
- **Stateless Service**
if you want to get more information about the stateful, you should visit [StatefulSet](../statefulsets/)
Create a Stateless Service also create a **Deployment** workload.
## This is a demo to create a **Stateless Service**
For more information **Stateless**, please visit [Deployment](../../application-workloads/deployments)
### Step 1: click the **Create** button, choose Stateless Service
- **Stateful Service**
Create a Stateless Service also create a **Statefulset** workload.
For more information **Statefulset**, please visit [Statefulset](../../application-workloads/statefulsets)
- **External Service**
The service created by External Service is a service internet access method. It is different from Stateless and stateful.
- **Specify Workloads**
Create a service with existing Pods.
- **Edit by YAML**
Create directly with Yaml, you can upload and download Yaml configuration files
{{< notice tip>}}
The value of `annotations:kubesphere.io/serviceType` keywords is one of them **statelessservice** , **statefulservice** , **externalservice** and **None**.
{{</ notice>}}
## Create a **Stateless Service**
Into **Application Workload**, click **Services**
### Step 1: click the **Create**, choose **Stateless Service**
![services_lists](/images/docs/project-user-guide/workloads/services_lists.png)
![stateless_form](/images/docs/project-user-guide/workloads/stateless_form.png)
### Step 2: input base info
### Step 2: Input Base data
![stateless_form_1](/images/docs/project-user-guide/workloads/stateless_form_1.png)
These are the YAML config keywords which display in the form label
| Label | Key |
| ----------- | -------------------------------------- |
| Name | metadata.name |
| Version | apiVersion |
| Alias | annotations.kubesphere.io\/alias-name |
| Description | annotations.kubesphere.io\/description |
- **Name**: The name of the Service and Deployment, which is also the unique identifier.
- **Alias**: The alias name of the service, making resources easier to identify.
- **Version**: It can only contain lowercase letters and numbers. The maximum length of characters is set to 16.
{{< notice tip >}}
@ -85,170 +126,42 @@ spec:
### Step 3: Input Container Image
#### 3.1 Input data exclude Container
In this step, you can know some configs exclude the container config which has more configs.
![stateless_form_2.png](/images/docs/project-user-guide/workloads/stateless_form_2.png)
These are the YAML config keywords which display in the form label
To add a container for the service, please refer to [Pod Containers](../deployments) for details.
| Label | key |
| -------------------------------------- | ------------------------ |
| Pod Replicas | replicas |
| Update Strategy | strategy.type |
| The number of Pods when updated | rollingUpdate |
| The maximum unavailable number of Pods | maxUnavailable |
| The maximum surge number of Pods | maxSurge |
| Pod Security Context | securityContext |
| run as non root | runAsNonRoot |
| User | runAsUser |
| Group | runAsGroup |
| seLinuxOptions | seLinuxOptions |
| Level | level |
| Role | role |
| Type | type |
| User | user |
| Pod Aggregation Deployment | affinity.podAntiAffinity |
#### 3.2 input Container info
In this step, you can know Container configs.
Click **Add Container Image**
![stateless_form_2_add_container](/images/docs/project-user-guide/workloads/stateless_form_2_container_1_add.png)
![stateless_form_2_container_1](/images/docs/project-user-guide/workloads/stateless_form_2_container_1_input.png)
these are the YAML config keywords which display in the form label
- Container
| label | key |
| -------------- | ---------- |
| Image | image |
| Container Name | name |
| Container Type | containers |
![stateless_form_2_container_2](/images/docs/project-user-guide/workloads/stateless_form_2_container_2.png)
- Resources
| label | key |
| ----------------- | ----------------- |
| Resources Request | resources.request |
| Resources limit | resources.limits |
| Service Settings | ports |
| PullImages | imagePullPolicy |
![stateless_form_2_container_3](/images/docs/project-user-guide/workloads/stateless_form_2_container_3.png)
- Health Check
| label | key |
| ------------------------- | -------------- |
| Container Liveness Check | livenessProbe |
| Container Readiness Check | readinessProbe |
| Container Startup Check | startupProbe |
- Start Command
| label | key |
| ----------- | ------- |
| Run Command | command |
| Parameters | args |
- Environment Variables
| label | key |
| --------------------- | ----- |
| Environment Variables | env |
| Run Command | name |
| Parameters | value |
- Container Security Context
| label | key |
| -------------------------- | ------------------------ |
| Container Security Context | securityContext |
| AllowPrivilegeEscalation | allowPrivilegeEscalation |
| ReadOnlyRootFilesystem | readOnlyRootFilesystem |
| Privileged | privileged |
| run as non root | runAsNonRoot |
| User | runAsUser |
| Group | runAsGroup |
| seLinuxOptions | seLinuxOptions |
| Level | level |
| Role | role |
| Type | type |
| User | user |
| Capabilities (Beta) | capabilities |
| add | add |
| drop | drop |
when you click the **check** button, the container has added in the list
![stateless_form_2_container_item](/images/docs/project-user-guide/workloads/stateless_form_2_container_item.png)
and you can also click **delete icon** or **editor icon** to operate it,
### Step 4: input Volume
### Step 4: Input Volume
![stateless_form_3](/images/docs/project-user-guide/workloads/stateless_form_3.png)
#### 4.1 choose the Volume
![stateless_form_3_volume](/images/docs/project-user-guide/workloads/stateless_form_3_volume.png)
{{< notice tip >}}
you can get more information in [volumes](../../storage/volumes/)
{{</ notice >}}
#### 4.2 choose the Mount ConfigMap or Secret
![stateless_form_3_volume_configmap](/images/docs/project-user-guide/workloads/stateless_form_3_volume_configmap.png)
{{< notice tip >}}
you can get more information in [configmaps](../../configuration/configmaps)
{{</ notice >}}
Refer to [Pod Volumes](../deployments) for details.
### Step 5: input Advanced Settings
![stateless_form_4](/images/docs/project-user-guide/workloads/stateless_form_4.png)
these are the YAML config keywords which display in the form label
Refer to [Deployment Advanced Settings](../deployments) for details.
| Advanced Setting | |
| --------------------------- | --------------------------------------------- |
| Access Method | type |
| Maximum Session Sticky Time | sessionAffinityConfig.clientIP.timeoutSeconds |
| Set Node Scheduling Policy | spec.nodeSelector |
| Add Metadata | label is metadata.annotations |
## Check Service Detail
### Step 6: finish
### Service Operations
![stateless_finish](/images/docs/project-user-guide/workloads/services_lists_finish.png)
now the Stateless Service has created, you can click it to view more information about it.also you can click`more icon` to operate this service item include edit config and delete.
Now the Stateless Service has created, you can click it to view more information about it.also you can click **More** to operate this service item include edit config and delete.
## Service Internet Access
- **Edit**: Edit the base data.
- **Edit YAML**: Edit the YAML config.
- **Edit Service**: Edit the service config.
- **Edit Internet Access**: Edit the service internet access.
- **Delete**: When deleting a service, the associated resources will be displayed. If you check them, they will be deleted together with the service
- ClusterIP: Exposes the Service on a cluster-internal IP. Choosing this value makes the Service only reachable from within the cluster. This is the default ServiceType.
### Service Detail
- NodePort: Exposes the Service on each Node's IP at a static port (the NodePort). A ClusterIP Service, to which the NodePort Service routes, is automatically created. You'll be able to contact the NodePort Service, from outside the cluster, by requesting `<NodeIP>:<NodePort>`.
![stateless_finish](/images/docs/project-user-guide/workloads/services_detail.png)
- LoadBalancer: Exposes the Service externally using a cloud provider's load balancer. NodePort and ClusterIP Services, to which the external load balancer routes, are automatically created.
- ExternalName: Maps the Service to the contents of the `externalName` field (e.g. foo.bar.example.com), by returning a CNAME record
## Editor Internet Access
![stateless_Internet_Access](/images/docs/project-user-guide/workloads/stateless_form_internetAccess.png)
Now you know how to create a service in kubesphereand you could custom your own service in more configs.
if you want to get more information about [Service](https://kubernetes.io/docs/concepts/services-networking/service/), you can click it, Thank you.
- The **More** Operations is the same which in the services list.
- The pod list provides the pod's detail information(conditions, phase, node, pod ip, monitoring).
- You can view the container info by click the pod item.
- Click the container log icon to view the output logs of the container.
- You can view the pod detail page by click the pod name.

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 427 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 520 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 489 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 466 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 453 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 412 KiB