Skip to content

Commit

Permalink
Merge pull request #274 from zsnmwy/docs_mirror
Browse files Browse the repository at this point in the history
docs(installation): Add mirror
  • Loading branch information
qmhu authored May 6, 2022
2 parents ad77889 + dd3f16f commit 929595b
Show file tree
Hide file tree
Showing 6 changed files with 326 additions and 42 deletions.
13 changes: 13 additions & 0 deletions docs/assets/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ setTimeout(function () {
parentChinldNodes[0].remove()
}
}

// Handle tab label click
const labels = document.querySelectorAll("div.tabbed-labels > label")
for (let i = 0; i < labels.length; i++) {
let tmp = labels[i]
tmp.onclick = () => {
for (const label of labels) {
if (label.textContent === tmp.textContent) {
label.click()
}
}
}
}
})
})
},1)
107 changes: 85 additions & 22 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,79 @@ Please refer to Helm's [documentation](https://helm.sh/docs/intro/install/) for
!!! note
If you already deployed prometheus, grafana in your environment, then skip this step.

!!! Warning "Network Problems"
If your network is hard to connect GitHub resources, you can try the mirror repo. Like GitHub Release, GitHub Raw Content `raw.githubusercontent.com`.

But mirror repo has a certain **latency**.[Mirror Repo](mirror.md)

Crane use prometheus to be the default metric provider.

Using following command to install prometheus components: prometheus-server, node-exporter, kube-state-metrics.

```bash
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install prometheus -n crane-system --set pushgateway.enabled=false --set alertmanager.enabled=false --set server.persistentVolume.enabled=false -f https://raw.githubusercontent.com/gocrane/helm-charts/main/integration/prometheus/override_values.yaml --create-namespace prometheus-community/prometheus
```

=== "Main"

```bash
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install prometheus -n crane-system \
--set pushgateway.enabled=false \
--set alertmanager.enabled=false \
--set server.persistentVolume.enabled=false \
-f https://raw.githubusercontent.com/gocrane/helm-charts/main/integration/prometheus/override_values.yaml \
--create-namespace prometheus-community/prometheus
```

=== "Mirror"

```bash
helm repo add prometheus-community https://finops-helm.pkg.coding.net/gocrane/prometheus-community
helm install prometheus -n crane-system \
--set pushgateway.enabled=false \
--set alertmanager.enabled=false \
--set server.persistentVolume.enabled=false \
-f https://finops.coding.net/p/gocrane/d/helm-charts/git/raw/main/integration/prometheus/override_values.yaml?download=false \
--create-namespace prometheus-community/prometheus
```
Fadvisor use grafana to present cost estimates. Using following command to install a grafana.

```bash
helm repo add grafana https://grafana.github.io/helm-charts
helm install grafana -f https://raw.githubusercontent.com/gocrane/helm-charts/main/integration/grafana/override_values.yaml -n crane-system --create-namespace grafana/grafana
```

=== "Main"

```bash
helm repo add grafana https://grafana.github.io/helm-charts
helm install grafana \
-f https://raw.githubusercontent.com/gocrane/helm-charts/main/integration/grafana/override_values.yaml \
-n crane-system \
--create-namespace grafana/grafana
```

=== "Mirror"

```bash
helm repo add grafana https://finops-helm.pkg.coding.net/gocrane/grafana
helm install grafana \
-f https://finops.coding.net/p/gocrane/d/helm-charts/git/raw/main/integration/grafana/override_values.yaml?download=false \
-n crane-system \
--create-namespace grafana/grafana
```

### Deploying Crane and Fadvisor

```bash
helm repo add crane https://gocrane.github.io/helm-charts
helm install crane -n crane-system --create-namespace crane/crane
helm install fadvisor -n crane-system --create-namespace crane/fadvisor
```

=== "Main"

```bash
helm repo add crane https://gocrane.github.io/helm-charts
helm install crane -n crane-system --create-namespace crane/crane
helm install fadvisor -n crane-system --create-namespace crane/fadvisor
```

=== "Mirror"

```bash
helm repo add crane https://finops-helm.pkg.coding.net/gocrane/gocrane
helm install crane -n crane-system --create-namespace crane/crane
helm install fadvisor -n crane-system --create-namespace crane/fadvisor
```

### Deploying Crane-scheduler(optional)
```bash
Expand Down Expand Up @@ -75,14 +125,27 @@ you can see [this](https://github.com/gocrane/helm-charts) to learn more.

Deploy `Crane` by apply YAML declaration.

```bash
git clone https://github.com/gocrane/crane.git
CRANE_LATEST_VERSION=$(curl -s https://api.github.com/repos/gocrane/crane/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
git checkout $CRANE_LATEST_VERSION
kubectl apply -f deploy/manifests
kubectl apply -f deploy/craned
kubectl apply -f deploy/metric-adapter
```
=== "Main"

```bash
git clone https://github.com/gocrane/crane.git
CRANE_LATEST_VERSION=$(curl -s https://api.github.com/repos/gocrane/crane/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
git checkout $CRANE_LATEST_VERSION
kubectl apply -f deploy/manifests
kubectl apply -f deploy/craned
kubectl apply -f deploy/metric-adapter
```

=== "Mirror"

```bash
git clone https://e.coding.net/finops/gocrane/crane.git
CRANE_LATEST_VERSION=$(curl -s https://api.github.com/repos/gocrane/crane/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
git checkout $CRANE_LATEST_VERSION
kubectl apply -f deploy/manifests
kubectl apply -f deploy/craned
kubectl apply -f deploy/metric-adapter
```

The following command will configure prometheus http address for crane if you want to customize it. Specify `CUSTOMIZE_PROMETHEUS` if you have existing prometheus server.

Expand Down
107 changes: 87 additions & 20 deletions docs/installation.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,81 @@ Crane 安装时间在10分钟左右,具体时间也依赖集群规模以及硬

使用 Helm 安装 Prometheus 和 Grafana。

> 注意:如果您已经在环境中部署了 Prometheus 和 Grafana,可以跳过该步骤。
!!! Note "注意"
如果您已经在环境中部署了 Prometheus 和 Grafana,可以跳过该步骤。

!!! Warning "网络问题"
如果你的网络无法访问GitHub资源(GitHub Release, GitHub Raw Content `raw.githubusercontent.com`)。

那么你可以尝试镜像仓库。但镜像仓库具有一定的**时延**[镜像仓库](mirror.zh.md)


Crane 使用 Prometheus 抓取集群工作负载对资源的使用情况。安装 Prometheus:

```shell
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install prometheus -n crane-system --set pushgateway.enabled=false --set alertmanager.enabled=false --set server.persistentVolume.enabled=false -f https://raw.githubusercontent.com/gocrane/helm-charts/main/integration/prometheus/override_values.yaml --create-namespace prometheus-community/prometheus
```
=== "Main"

```bash
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install prometheus -n crane-system \
--set pushgateway.enabled=false \
--set alertmanager.enabled=false \
--set server.persistentVolume.enabled=false \
-f https://raw.githubusercontent.com/gocrane/helm-charts/main/integration/prometheus/override_values.yaml \
--create-namespace prometheus-community/prometheus
```

=== "Mirror"

```bash
helm repo add prometheus-community https://finops-helm.pkg.coding.net/gocrane/prometheus-community
helm install prometheus -n crane-system \
--set pushgateway.enabled=false \
--set alertmanager.enabled=false \
--set server.persistentVolume.enabled=false \
-f https://finops.coding.net/p/gocrane/d/helm-charts/git/raw/main/integration/prometheus/override_values.yaml?download=false \
--create-namespace prometheus-community/prometheus
```


Crane 的 Fadvisor 使用 Grafana 展示成本预估。安装 Grafana:

```console
helm repo add grafana https://grafana.github.io/helm-charts
helm install grafana -f https://raw.githubusercontent.com/gocrane/helm-charts/main/integration/grafana/override_values.yaml -n crane-system --create-namespace grafana/grafana
```
=== "Main"

```bash
helm repo add grafana https://grafana.github.io/helm-charts
helm install grafana \
-f https://raw.githubusercontent.com/gocrane/helm-charts/main/integration/grafana/override_values.yaml \
-n crane-system \
--create-namespace grafana/grafana
```

=== "Mirror"

```bash
helm repo add grafana https://finops-helm.pkg.coding.net/gocrane/grafana
helm install grafana \
-f https://finops.coding.net/p/gocrane/d/helm-charts/git/raw/main/integration/grafana/override_values.yaml?download=false \
-n crane-system \
--create-namespace grafana/grafana
```

### 安装 Crane 和 Fadvisor

```console
helm repo add crane https://gocrane.github.io/helm-charts
helm install crane -n crane-system --create-namespace crane/crane
helm install fadvisor -n crane-system --create-namespace crane/fadvisor
```
=== "Main"

```bash
helm repo add crane https://gocrane.github.io/helm-charts
helm install crane -n crane-system --create-namespace crane/crane
helm install fadvisor -n crane-system --create-namespace crane/fadvisor
```

=== "Mirror"

```bash
helm repo add crane https://finops-helm.pkg.coding.net/gocrane/gocrane
helm install crane -n crane-system --create-namespace crane/crane
helm install fadvisor -n crane-system --create-namespace crane/fadvisor
```

### 安装 Crane-scheduler(可选)
```console
Expand Down Expand Up @@ -104,12 +156,27 @@ kubectl port-forward -n crane-system svc/craned 9090

通过 YAML 安装 `Crane`

```console
git checkout v0.2.0
kubectl apply -f deploy/manifests
kubectl apply -f deploy/craned
kubectl apply -f deploy/metric-adapter
```
=== "Main"

```bash
git clone https://github.com/gocrane/crane.git
CRANE_LATEST_VERSION=$(curl -s https://api.github.com/repos/gocrane/crane/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
git checkout $CRANE_LATEST_VERSION
kubectl apply -f deploy/manifests
kubectl apply -f deploy/craned
kubectl apply -f deploy/metric-adapter
```

=== "Mirror"

```bash
git clone https://e.coding.net/finops/gocrane/crane.git
CRANE_LATEST_VERSION=$(curl -s https://api.github.com/repos/gocrane/crane/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
git checkout $CRANE_LATEST_VERSION
kubectl apply -f deploy/manifests
kubectl apply -f deploy/craned
kubectl apply -f deploy/metric-adapter
```

如果您想自定义 Crane 里配置 Prometheus 的 HTTP 地址,请参考以下的命令。如果您在集群里已存在一个 Prometheus,请将 Server 地址填于`CUSTOMIZE_PROMETHEUS`

Expand Down
70 changes: 70 additions & 0 deletions docs/mirror.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Mirror Repo


## About mirror repo

Because of various network issues, it is difficult to access GitHub resources such as GitHub Repo, GitHub Release, GitHub Raw Content `raw.githubusercontent.com` in some regions.

For a better experience, GoCrane offers several additional mirror repositories for you, but with some latency.

## Helm Resources

!!! tips
Sync the latest version of upstream every six hours

| Origin | Mirror | Type | Public |
| --------------------------------------------- | --------------------------------------------------------- | ------ | ----- |
| https://gocrane.github.io/helm-charts | https://finops-helm.pkg.coding.net/gocrane/gocrane | Helm | [Public](https://finops.coding.net/public-artifacts/gocrane/gocrane/packages) |
| https://prometheus-community.github.io/helm-charts | https://finops-helm.pkg.coding.net/gocrane/prometheus-community | Helm | [Public](https://finops.coding.net/public-artifacts/gocrane/prometheus-community/packages) |
| https://grafana.github.io/helm-charts | https://finops-helm.pkg.coding.net/gocrane/grafana | Helm | [Public](https://finops.coding.net/public-artifacts/gocrane/grafana/packages) |

## Git Resources

!!! tips
Sync upstream repository every day

| Origin | Mirror | Type | Public |
| --------------------------------------------- | --------------------------------------------------------- | ------ | ---- |
| https://github.com/gocrane/crane.git | https://e.coding.net/finops/gocrane/crane.git | Git | [Public](https://finops.coding.net/public/gocrane/crane/git/files) |
| https://github.com/gocrane/helm-charts.git | https://e.coding.net/finops/gocrane/helm-charts.git | Git | [Public](https://finops.coding.net/public/gocrane/helm-charts/git/files) |
| https://github.com/gocrane/api.git | https://e.coding.net/finops/gocrane/api.git | Git | [Public](https://finops.coding.net/public/gocrane/api/git/files) |
| https://github.com/gocrane/crane-scheduler.git | https://e.coding.net/finops/gocrane/crane-scheduler.git | Git | [Public](https://finops.coding.net/public/gocrane/crane-scheduler/git/files) |
| https://github.com/gocrane/fadvisor.git | https://e.coding.net/finops/gocrane/fadvisor.git | Git | [Public](https://finops.coding.net/public/gocrane/fadvisor/git/files) |

## Get the raw file contents of the Coding repo

Here you'll find out how to get the contents of a source file directly from the Coding Git repository via an HTTP request.

### Coding Git Repo - Key Params

Similar to regular API requests, the Coding Git repository provides a corresponding API interface.

The following is an overview of the related parameters.

!!! tips Example "Example"
Using https://**finops**.coding.net/public/**gocrane**/**helm-charts**/git/files**/main/integration/grafana/override_values.yaml** as an example. [Click Here](https://finops.coding.net/public/gocrane/helm-charts/git/files/main/integration/grafana/override_values.yaml)

| Params | Description | example |
| ---- | ---- | ---- |
| `team` | Name of the team | `finops` |
| `project` | Name of the project | `gocrane` |
| `repo` | Name of the Git Repo | `helm-charts` |
| `branch` | Name of the branch | `main` |
| `file path` | The path to the file in the repo | `/integration/grafana/override_values.yaml` |

### Constructing HTTP requests

By filling in the following URL construction rules according to the properties mentioned above, you can obtain a URL that can directly access the content of the source file.

```bash
https://<team>.coding.net/p/<project>/d/<repo>/git/raw/<branch>/<file path>?download=false

https://finops.coding.net/p/gocrane/d/helm-charts/git/raw/main/integration/grafana/override_values.yaml?download=false
```

!!! tips
Try this command.

```bash
curl https://finops.coding.net/p/gocrane/d/helm-charts/git/raw/main/integration/grafana/override_values.yaml?download=false
```
Loading

0 comments on commit 929595b

Please sign in to comment.