Skip to content

Commit

Permalink
Quickstart optimization
Browse files Browse the repository at this point in the history
Signed-off-by: lfbear <[email protected]>
  • Loading branch information
lfbear committed Sep 18, 2021
1 parent 46df7a6 commit f28cce6
Show file tree
Hide file tree
Showing 12 changed files with 169 additions and 266 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
with:
go-version: 1.16.x
- name: setup e2e test environment
run: hack/karmada-bootstrap.sh
run: hack/local-up-karmada.sh
- name: run e2e
run: hack/run-e2e.sh
- name: upload logs
Expand Down
86 changes: 15 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ This guide will cover:
- Join a member cluster to `karmada` control plane.
- Propagate an application by `karmada`.

### Demo

There are several demonstrations of common cases.

![Demo](docs/images/demo-3in1.svg)

### Prerequisites
- [Go](https://golang.org/) version v1.16+
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) version v1.19+
Expand All @@ -118,90 +112,40 @@ cd karmada

#### 3. Deploy and run karmada control plane:

run the following script: (It will create a host cluster by kind)
run the following script:

```
hack/local-up-karmada.sh
# hack/local-up-karmada.sh
```
The script `hack/local-up-karmada.sh` will do following tasks for you:
This script will do following tasks for you:
- Start a Kubernetes cluster to run the karmada control plane, aka. the `host cluster`.
- Build karmada control plane components based on a current codebase.
- Deploy karmada control plane components on `host cluster`.
- Create member clusters and join to Karmada.

If everything goes well, at the end of the script output, you will see similar messages as follows:
```
Local Karmada is running.
Kubeconfig for karmada is in file: /root/.kube/karmada.config, so you can run:
export KUBECONFIG="/root/.kube/karmada.config"
Or use kubectl with --kubeconfig=/root/.kube/karmada.config
Please use 'kubectl config use-context <Context_Name>' to switch clusters.
The following is context intro:
------------------------------------------------------
| Context Name | Purpose |
|----------------------------------------------------|
| karmada-host | the cluster karmada install in |
|----------------------------------------------------|
| karmada-apiserver | karmada control plane |
------------------------------------------------------
To start using your karmada, run:
export KUBECONFIG=/root/.kube/karmada.config
Please use 'kubectl config use-context karmada-host/karmada-apiserver' to switch the host and control plane cluster.
To manage your member clusters, run:
export KUBECONFIG=/root/.kube/members.config
Please use 'kubectl config use-context member1/member2/member3' to switch to the different member cluster.
```

There are two contexts:
There are two contexts about karmada:
- karmada-apiserver `kubectl config use-context karmada-apiserver`
- karmada-host `kubectl config use-context karmada-host`

The `karmada-apiserver` is the **main kubeconfig** to be used when interacting with karamda control plane, while `karmada-host` is only used for debugging karmada installation with the host cluster. You can check all clusters at any time by running: `kubectl config view`. To switch cluster contexts, run `kubectl config use-context [CONTEXT_NAME]`

#### Tips
- Please make sure you can access google cloud registry: k8s.gcr.io
- Install script will download golang package, if your server is in the mainland China, you may set go proxy like this `export GOPROXY=https://goproxy.cn`

### Join member cluster
In the following steps, we are going to create a member cluster and then join the cluster to
karmada control plane.

#### 1. Create member cluster
We are going to create a cluster named `member1` and we want the `KUBECONFIG` file
in `$HOME/.kube/karmada.config`. Run following command:
```
hack/create-cluster.sh member1 $HOME/.kube/karmada.config
```
The script `hack/create-cluster.sh` will create a cluster by kind.

#### 2. Join member cluster to karmada control plane

You can choose one of mode: [push](#21-push-mode-karmada-controls-the-member-cluster-initiative-by-using-karmadactl) or
[pull](#22-pull-mode-installing-karmada-agent-in-the-member-cluster), either will help you join a member cluster.

##### 2.1. Push Mode: Karmada controls the member cluster initiative by using `karmadactl`

The command `karmadactl` will help to join the member cluster to karmada control plane,
before that, we should switch to karmada apiserver:
```
kubectl config use-context karmada-apiserver
```

Then, install `karmadactl` command and join the member cluster:
```
go get github.com/karmada-io/karmada/cmd/karmadactl
karmadactl join member1 --cluster-kubeconfig=$HOME/.kube/karmada.config
```
The `karmadactl join` command will create a `Cluster` object to reflect the member cluster.

##### 2.2. Pull Mode: Installing karmada-agent in the member cluster

The following script will install the `karamda-agent` to your member cluster, you need to specify the kubeconfig and the cluster context of the karmada control plane and member cluster.
```
hack/deploy-karmada-agent.sh <karmada_apiserver_kubeconfig> <karmada_apiserver_context_name> <member_cluster_kubeconfig> <member_cluster_context_name>
```
### Demo

#### 3. Check member cluster status
Now, check the member clusters from karmada control plane by following command:
```
$ kubectl get clusters
NAME VERSION MODE READY AGE
member1 v1.20.2 Push True 66s
```
![Demo](docs/images/sample-nginx.svg)

### Propagate application
In the following steps, we are going to propagate a deployment by karmada.
Expand All @@ -223,7 +167,7 @@ You can check deployment status from karmada, don't need to access member cluste
```
$ kubectl get deployment
NAME READY UP-TO-DATE AVAILABLE AGE
nginx 1/1 1 1 43s
nginx 2/2 2 2 20s
```

## Kubernetes compatibility
Expand Down
1 change: 1 addition & 0 deletions docs/images/sample-nginx.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/multi-cluster-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ Users are able to **export** and **import** services between clusters with [Mult

### Karmada has been installed

We can install Karmada by referring to [quick-start](https://github.com/karmada-io/karmada#quick-start), or directly run `hack/karmada-bootstrap.sh` script which is also used to run our E2E cases.
We can install Karmada by referring to [quick-start](https://github.com/karmada-io/karmada#quick-start), or directly run `hack/local-up-karmada.sh` script which is also used to run our E2E cases.

### Member Cluster Network

Ensure that at least two clusters have been added to Karmada, and the container networks between member clusters are connected.

- If you use the `hack/karmada-bootstrap.sh` script to deploy Karmada, Karmada will have three member clusters, and the container networks of the `member1` and `member2` will be connected.
- If you use the `hack/local-up-karmada.sh` script to deploy Karmada, Karmada will have three member clusters, and the container networks of the `member1` and `member2` will be connected.
- If you use `Kind` tool to create member clusters, you can refer to the [hack/util.sh](https://github.com/karmada-io/karmada/blob/af5f544cbe68d6b37a730b42dcc1ead0fac16915/hack/util.sh#L452-L470) script to enable the container networks.

### The ServiceExport and ServiceImport CRDs have been installed
Expand Down
15 changes: 15 additions & 0 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Troubleshooting

## I can't access some resources when install Karmada

- Pulling images from Google Container Registry(k8s.gcr.io)

You may run the following command to change the image registry in the mainland China
```shell
sed -i'' -e "s#k8s.gcr.io#registry.aliyuncs.com/google_containers#g" artifacts/deploy/karmada-etcd.yaml
sed -i'' -e "s#k8s.gcr.io#registry.aliyuncs.com/google_containers#g" artifacts/deploy/karmada-apiserver.yaml
sed -i'' -e "s#k8s.gcr.io#registry.aliyuncs.com/google_containers#g" artifacts/deploy/kube-controller-manager.yaml
```
- Download golang package in the mainland China, run the following command before installing
```shell
export GOPROXY=https://goproxy.cn
2 changes: 1 addition & 1 deletion docs/working-with-argocd.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You have installed Argo CD following the instructions in [Getting Started](https
### Karmada Installation
In this example, we are using a Karmada environment with at lease `3` member clusters joined.

You can set up the environment by `hack/karmada-bootstrap.sh`, which is also used to run our E2E cases.
You can set up the environment by `hack/local-up-karmada.sh`, which is also used to run our E2E cases.

```bash
# kubectl get clusters
Expand Down
22 changes: 13 additions & 9 deletions hack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ ensures development quality.

## For end-user

- [`local-up-karmada.sh`](local-up-karmada.sh) This script will quickly set up a local development environment based on the current codebase.
- [`local-up-karmada.sh`](local-up-karmada.sh) This script will quickly set up a local development environment with member clusters based on the current codebase.

- [`remote-up-karmada.sh`](remote-up-karmada.sh) This script will install Karmada to a standalone K8s cluster, this cluster
may be real, remote , and even for production. It is worth noting for the connectivity from your client to Karmada API server,
it will create a load balancer service with an external IP by default, if your want to customize this service, you may add
the annotations at the metadata part of service `karmada-apiserver` in
it will create a load balancer service with an external IP by default, else type `export CLUSTER_IP_ONLY=true` with the `ClusterIP` type service before the following script.
If your want to customize a load balancer service, you may add the annotations at the metadata part of service `karmada-apiserver` in
[`../artifacts/deploy/karmada-apiserver.yaml`](../artifacts/deploy/karmada-apiserver.yaml) before the installing. The
following is an example.
```
Expand All @@ -29,6 +29,13 @@ ensures development quality.
# Tencent cloud (you need to replace words 'xxxxxxxx')
#service.kubernetes.io/qcloud-loadbalancer-internal-subnetid: subnet-xxxxxxxx
```
The usage of `remote-up-karmada.sh`:
```
# hack/remote-up-karmada.sh <kubeconfig> <context_name>
```
`kubeconfig` is your cluster's kubeconfig that you want to install to

`context_name` is the name of context in 'kubeconfig'

- [`deploy-karmada-agent.sh`](deploy-karmada-agent.sh) This script will install Karmada Agent to the specific cluster.

Expand All @@ -38,16 +45,13 @@ ensures development quality.
the installing step.

## For CI pipeline
- [`karmada-bootstrap.sh`](karmada-bootstrap.sh) This script will quickly pull up a local Karmada environment too,
what is different from `local-up-karmada.sh` is it will pull up member clusters. This is usually for testing,
of course, you may also use it for your local environment.
- [`local-up-karmada.sh`](local-up-karmada.sh) This script also used for testing.

- [`run-e2e.sh`](run-e2e.sh) This script runs e2e test against on Karmada control plane. You should prepare your environment
in advance with `karmada-bootstrap.sh`.
in advance with `local-up-karmada.sh`.

## Some internal scripts
These scripts are not intended used by end-users, just for the development
- [`deploy-karmada.sh`](deploy-karmada.sh) Underlying common implementation for `local-up-karmada.sh`, `remote-up-karmada.sh`
and `karmada-bootstrap.sh`
- [`deploy-karmada.sh`](deploy-karmada.sh) Underlying common implementation for `local-up-karmada.sh` and `remote-up-karmada.sh`.

- [`util.sh`](util.sh) All util functions.
119 changes: 0 additions & 119 deletions hack/karmada-bootstrap.sh

This file was deleted.

Loading

0 comments on commit f28cce6

Please sign in to comment.