Skip to content

Commit

Permalink
feat: add some codes about helm deploy for kosmos-website
Browse files Browse the repository at this point in the history
Signed-off-by: yuleichun2019 <[email protected]>
  • Loading branch information
yuleichun-striving committed Oct 21, 2024
1 parent 0ce6a65 commit 1011393
Show file tree
Hide file tree
Showing 20 changed files with 314 additions and 75 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
This repo contains the source code of [Kosmos website](https://kosmos-io.github.io/website/) and all of the docs for Kosmos.
It's built by [Docusaurus](https://docusaurus.io/), a modern static website generator.

- [Kosmos website](https://kosmos-io.github.io/website/)
- [Kosmos docs](https://kosmos-io.github.io/website/getting-started/introduction)
- [Kosmos website](https://kosmos-io.github.io/kosmos-website/)
- [Kosmos docs](https://kosmos-io.github.io/kosmos-website/docs/getting-started/introduction)

Welcome to join us and you are more than appreciated to contribute!

Expand Down
4 changes: 2 additions & 2 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
这个仓库包含了[Kosmos 网站](https://kosmos-io.github.io/website/)的源代码以及所有的 Kosmos 文档。
它是由[Docusaurus](https://docusaurus.io/)构建的,一个现代的静态网站生成器。

- [Kosmos 网站](https://kosmos-io.github.io/website/)
- [Kosmos 文档](https://kosmos-io.github.io/website/getting-started/introduction)
- [Kosmos 网站](https://kosmos-io.github.io/kosmos-website/)
- [Kosmos 文档](https://kosmos-io.github.io/kosmos-website/docs/getting-started/introduction)

欢迎加入我们,非常感谢您的贡献!

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/getting-started/img/host_ippools_check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/getting-started/img/host_vx_check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/getting-started/img/manager-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/getting-started/img/member_ippools_check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/getting-started/img/member_vx_check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
170 changes: 145 additions & 25 deletions docs/getting-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ title: 'Quick Start'
# Quick Start
This guide will cover:
- Use Kind create three kubernetes cluster
- Install `kosmosctl`, you can download from the <a href="https://github.com/kosmos-io/kosmos/releases">releases page</a> or build from source
- Install `kosmos` control plane components in a Kubernetes cluster which is known as `host cluster`.
- Join a member cluster to `kosmos` control plane on the `host cluster`.
- Use the Kosmos clusters.
- Enabling cross-cluster deployment of applications through Kosmos.

## Prerequisites
- [Go](https://golang.org/) version v1.20+
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) version v1.19+
- [kind](https://kind.sigs.k8s.io/) version v0.14.0+
- [helm](https://github.com/helm/helm/releases) version v3.11.0+

## Deploy and run Kosmos control plane use script
## Deploy and run Kosmos use script
run the following script:

```bash
git clone https://github.com/kosmos-io/kosmos.git && cd kosmos
hack/local-up-kosmosctl.sh
hack/local-up-kosmos.sh
```


## Deploy and run Kosmos step by step
## Deploy and run Kosmos use `kosmosctl`

### 1. Use Kind create cluster
- Config your kind cluster use flow config, change the param as you need
Expand All @@ -51,54 +51,54 @@ nodes:
#- role: worker
```
- create cluster1

`kind create cluster -n kind-cluster1 --config /path/to/kind-config`
- create cluster2

`kind create cluster -n kind-cluster2 --config /path/to/kind-config`
- create cluster3

`kind create cluster -n kind-cluster3 --config /path/to/kind-config`

### 2. Install `kosmosctl`
Kosmos is equipped with a tool called kosmosctl, which allows for quick deployment of Kosmos components, adding clusters, and testing network connectivity.
### 2. Install `kosmosctl` client
Kosmos is equipped with a tool called kosmosctl, which allows for quick deployment of Kosmos components, adding clusters, and testing network connectivity.Install `kosmosctl`, you can download from the <a href="https://github.com/kosmos-io/kosmos/releases">releases page</a> or build from source

#### 2.1 Use prebuild Binary executable file
#### 2.1 Method 1:Use prebuild Binary executable file
- Download from the <a href="https://github.com/kosmos-io/kosmos/releases">releases page</a>, only support macOS and linux
- put `kosmosctl` to you Path, so you can execute `kosmosctl` without absolute path
- recommend use linux to install kosmosctl
```bash
wget -cO kosmosctl-linux-amd64 https://github.com/kosmos-io/kosmos/releases/download/v0.2.0-lts/kosmosctl-linux-amd64
chmod +x kosmosctl-linux-amd64 && sudo install -m 755 kosmosctl-linux-amd64 /usr/local/bin/kosmosctl
```
#### 2.2 Build from source
#### 2.2 Method 2:Build from source
- Download source
`git clone https://github.com/kosmos-io/kosmos.git`
- Build code, the output file is in the` <project_dir>/_output/bin/linux/amd64/kosmosctl`
`make kosmosctl VERSION=v0.1.9`]
- you can find any available version or tags in [here](https://github.com/kosmos-io/kosmos/tags)

### 3. Install `kosmos` control plane components
The following command allows you to quickly run an experimental environment with three clusters.
Install the control plane in the host cluster.
Please config the pod can access the kind cluster apiServer, avoid the `kosmos-operator` CrashLoopBackOff
- Install the control plane in the `host cluster`. Please config the pod can access the kind cluster apiServer, avoid the `kosmos-operator` CrashLoopBackOff
```Shell
kosmosctl install --cni calico --default-nic eth0 (We build a network tunnel based the network interface value passed by the arg default-nic)
kosmosctl install --cni calico --default-nic eth0 //We build a network tunnel based the network interface value passed by the arg default-nic
```
### 4. Join to `kosmos` control plane
- Get the cluster1 and cluster2 kubeconfig and put it on the host cluster
- Join the two member clusters(execute on the host cluster).
### 4. Cluster management
- Get the cluster2 and cluster3 kubeconfig and put it on the `host cluster`,join the two member clusters(execute on the host cluster).
```Shell
kosmosctl join cluster --name cluster1 --kubeconfig ~/kubeconfig/cluster1-kubeconfig --cni calico --default-nic eth0 --enable-all
kosmosctl join cluster --name cluster2 --kubeconfig ~/kubeconfig/cluster2-kubeconfig --cni calico --default-nic eth0 --enable-all
kosmosctl join cluster --name cluster2 --kubeconfig ~/kubeconfig/cluster1-kubeconfig --cni calico --default-nic eth0 --enable-all
kosmosctl join cluster --name cluster3 --kubeconfig ~/kubeconfig/cluster2-kubeconfig --cni calico --default-nic eth0 --enable-all
```
### 5. Use the Kosmos clusters like single cluster on the control plane.
check cluster nodes status
### 5. Check the cluster management status(Use the Kosmos clusters like single cluster on the control plane)
- check cluster nodes status
```shell
kubectl get nodes
NAME STATUS ROLES AGE VERSION
kosmos-cluster1-control-plane Ready control-plane 9d v1.27.3
kosmos-cluster2 Ready agent 9d v1.27.3
kosmos-cluster3 Ready agent 9d v1.27.3
```
check cluster status
- check cluster status
```bash
kubectl get clusters
NAME NETWORK_TYPE IP_FAMILY
Expand All @@ -107,9 +107,129 @@ cluster3 gateway ipv4
kosmos-control-cluster gateway ipv4
```

## Deploy and run Kosmos use `Helm`

### 1. Use Kind create cluster
- Config your kind cluster use flow config, change the param as you need
```yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
# WARNING: It is _strongly_ recommended that you keep this the default
# (127.0.0.1) for security reasons. However it is possible to change this.
apiServerAddress: "192.168.200.112"
# By default the API server listens on a random open port.
# You may choose a specific port but probably don't need to in most cases.
# Using a random port makes it easier to spin up multiple clusters.
apiServerPort: 1443
nodes:
- role: control-plane
extraPortMappings:
- containerPort: "{{container_port}}"
hostPort: "{{host_port}}"
protocol: TCP
listenAddress: "{{host_ipaddress}}"
#- role: worker
#- role: worker
```
- create cluster1

`kind create cluster -n kind-cluster1 --config /path/to/kind-config`
- create cluster2

`kind create cluster -n kind-cluster2 --config /path/to/kind-config`
- create cluster3

`kind create cluster -n kind-cluster3 --config /path/to/kind-config`

### 2. Download the Helm deployment file for `Kosmos`
- Download the source code for Kosmos

`git clone https://github.com/kosmos-io/kosmos.git`

- Place the `kosmos` folder from the `charts` module of the source code into the `host cluster`.

### 3. Install `Kosmos` control plane components
- Install the control plane in the `host cluster`. Please config the pod can access the kind cluster apiServer, avoid the `kosmos-operator` CrashLoopBackOff,modify the configuration values in the `value.yaml` file within the downloaded `kosmos` folder (especially the ns, kubeconfig information in the main cluster, images, etc.) to meet the requirements of the current environment. For specific configuration details, refer to the comments.
```Shell
kubectl create ns kosmos-system

helm install kosmos -n kosmos-system kosmos

```

### 4. Check the installation status of the `Kosmos` control plane components
```Shell
kubectl get all -n kosmos-system

```
![manager-list.png](img/manager-list.png)

### 5. Cluster management
All cluster management operations by `Kosmos` are conducted within the host cluster, and both the host and member clusters need to be managed. Managing the host cluster facilitates subsequent management operations for the member clusters, as well as the inter-cluster container network integration. Place the `cluster_yaml` folder from the deploy module in the source code into the `host cluster`.
- Manage the `host cluster`

Modify the commented content in the `kosmos-control-cluster.yaml` file within `cluster_yaml`.
```Shell
kubectl apply -f kosmos-control-cluster.yaml

```
After successfully managing the `host cluster`, check if the cluster object for the `host cluster` has been created. You can see detailed information in the cluster object, particularly noting that the status section includes new `clusterLinkStatus` information, which encompasses `podCIDRS` and `serviceCIDRS`.
```Shell
kubectl get cluster kosmos-control-cluster -oyaml

```
- Manage the `member cluster`


Modify the contents of the comments in `member-cluster.yaml` (if there are multiple member clusters, multiple files are needed) to make them fully consistent with the information in the managed subordinate clusters (including node network interface card information, etc.).
```Shell
kubectl apply -f member-cluster.yaml

```
After successfully managing the `member cluster`, check whether the cluster object in the `member cluster` has been created. You can see detailed information in the cluster object, particularly the newly added `clusterLinkStatus` information in the status section, which includes `podCIDRS` and `serviceCIDRS`.
```Shell
kubectl get cluster member-cluster -oyaml

```
Verify in the `host cluster` whether the `member clusters` are successfully managed as `virtual nodes`.
```Shell
kubectl get nodes

```
`Kosmos` supports one-to-one cluster-level management and can also manage all or some nodes within a single cluster. The mode can be modified in the cluster object.

### 6. Check after successful `Kosmos` cluster management

- `host cluster` inspection

![host_ippools_check.png](img/host_ippools_check.png)


![host_clusternodes_check.png](img/host_clusternodes_check.png)


![host_nodeconfigs_check.png](img/host_nodeconfigs_check.png)

When cross-cluster container network issues arise, whether in `p2p` mode or `gateway` mode, network troubleshooting (such as packet capturing) can be carried out on the network interfaces prefixed with `vx` created by `Kosmos`.

![host_vx_check.png](img/host_vx_check.png)


- `member cluster` inspection

![member_service_check.png](img/member_service_check.png)


![member_vx_check.png](img/member_vx_check.png)


![member_ippools_check.png](img/member_ippools_check.png)


## Deploy nginx use kosmos

### create nginx deployment yaml
### Edit the Nginx service YAML

```yaml
apiVersion: apps/v1
Expand Down Expand Up @@ -139,11 +259,11 @@ spec:
- containerPort: 80

```
### apply the yaml
### Execute Nginx service YAML
```bash
kubectl apply -f nginx-deploy.yml
```
### check nginx pod status
### Check the status of Nginx service Pods

```bash
kubectl get pods -o wide
Expand All @@ -152,4 +272,4 @@ nginx-deployment-887b5c6bb-jx9kq 1/1 Running 0 18h 10.244.0.8
nginx-deployment-887b5c6bb-kc9ff 1/1 Running 0 41h 10.244.0.7 kosmos-cluster2 <none> <none>
nginx-deployment-887b5c6bb-vz8vk 1/1 Running 0 41h 10.244.0.7 kosmos-cluster3 <none> <none>
```
we can see the pod deployed to leaf cluster and in running status
To summarize, the cross-cluster deployment of the Nginx service based on Kosmos has been completed, with the service running in the member clusters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1011393

Please sign in to comment.