Skip to content

Commit b9ce6ad

Browse files
authored
Merge pull request #2 from 0xff-dev/main
feat: deploy fabirc-operator by helm
2 parents 1c80864 + c219b09 commit b9ce6ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+6791
-52
lines changed

.github/workflows/e2e.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: "installer e2e"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
suite:
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
- name: Kind
19+
run: |
20+
make kind
21+
- name: Install
22+
run: |
23+
make e2e

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
kind:
3+
./scripts/kind.sh
4+
5+
unkind:
6+
kind delete cluster -nkind
7+
e2e:
8+
./scripts/e2e.sh

README.md

Lines changed: 112 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,41 @@
11
Here is the steps about how to install bestchains BaaS platform
22

3-
## 1. Install u4a-component
3+
# Installer
4+
## Prerequisites
5+
6+
- [Install Docker](https://docs.docker.com/engine/install/)
7+
- [Install kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl)
8+
- [Install Helm](https://helm.sh/docs/intro/install/)
9+
- [Install kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
10+
- Get source code
11+
```shell
12+
$ git clone https://github.com/bestchains/installer.git;
13+
```
14+
15+
## Quick Start
16+
17+
Create a k8s cluster via kind and deploy the cluster component, u4a component and baas component.
18+
19+
```shell
20+
# if you don't have a k8s cluster, it will create a k8s cluster by kind
21+
make kind
22+
23+
# it will install cluster components, u4a-components and baas components
24+
make e2e
25+
```
26+
27+
## Manual deployment
28+
29+
### 1. Install u4a-component
430
For the 1st step, we'll install u4a-component and it'll provide the account, authentication, authorization and audit funcationality built on Kubernetes. And it has the capability to add more features following the guide later.
531

632
And then we'll deploy BaaS on top of it, and use OIDC token for SSO between u4a and baas component.
733

8-
### Install cluster tools
34+
#### 1.1 Install cluster tools
35+
936
Before deploy u4a, we should add some tools for later usage. Enter into u4a-component folder and following the step below:
1037

11-
* This step will install a ingress nginx controller with ingressclass named 'u4a-component-ingress' and cert-manager for certificate management.
38+
* This step will install a ingress nginx controller with ingressclass named 'portal-ingress' and cert-manager for certificate management.
1239

1340
```
1441
# 1. create a namespace to install u4a-component
@@ -35,7 +62,7 @@ cert-manager-cainjector-64685f8d48-qg69v 1/1 Running
3562
cert-manager-webhook-5c46d68c6b-f4dkh 1/1 Running 0 76m
3663
cluster-component-ingress-nginx-controller-5bd67897dd-5m9n7 1/1 Running 0 76m
3764
```
38-
### Install u4a services
65+
#### 1.2 Install u4a services
3966
Enter into u4a-component folder and following the step below:
4067

4168
This step will install the following services:
@@ -51,59 +78,108 @@ This step will install the following services:
5178
* you should also update the image address if you're using a private registry
5279

5380
2. Install u4a component using helm
54-
```
55-
# run helm install
56-
$ helm install --wait u4a-component -n u4a-system .
5781

58-
# wait for all pods to be ready
59-
$ kubectl get pod -n u4a-system
60-
NAME READY STATUS RESTARTS AGE
61-
bff-server-6c9b4b97f5-gqrx6 1/1 Running 0 45m
62-
capsule-controller-manager-6cf656b98c-sjm5n 1/1 Running 0 66m
63-
cert-manager-756fd78bff-wb2vh 1/1 Running 0 76m
64-
cert-manager-cainjector-64685f8d48-qg69v 1/1 Running 0 76m
65-
cert-manager-webhook-5c46d68c6b-f4dkh 1/1 Running 0 76m
66-
cluster-component-ingress-nginx-controller-5bd67897dd-5m9n7 1/1 Running 0 76m
67-
kube-oidc-proxy-5f4598c77c-fzl5q 1/1 Running 0 65m
68-
oidc-server-85db495594-k6pkt 2/2 Running 0 65m
69-
resource-view-controller-76d8c79cf-smkj5 1/1 Running 0 66m
70-
```
82+
```
83+
# run helm install
84+
$ helm install --wait u4a-component -n u4a-system .
85+
86+
# wait for all pods to be ready
87+
$ kubectl get pod -n u4a-system
88+
NAME READY STATUS RESTARTS AGE
89+
bff-server-6c9b4b97f5-gqrx6 1/1 Running 0 45m
90+
capsule-controller-manager-6cf656b98c-sjm5n 1/1 Running 0 66m
91+
cert-manager-756fd78bff-wb2vh 1/1 Running 0 76m
92+
cert-manager-cainjector-64685f8d48-qg69v 1/1 Running 0 76m
93+
cert-manager-webhook-5c46d68c6b-f4dkh 1/1 Running 0 76m
94+
cluster-component-ingress-nginx-controller-5bd67897dd-5m9n7 1/1 Running 0 76m
95+
kube-oidc-proxy-5f4598c77c-fzl5q 1/1 Running 0 65m
96+
oidc-server-85db495594-k6pkt 2/2 Running 0 65m
97+
resource-view-controller-76d8c79cf-smkj5 1/1 Running 0 66m
98+
```
99+
71100
3. At the end of the helm install, it'll prompt you with some notes like below:
72-
```
73-
NOTES:
74-
1. Get the ServiceAccount token by running these commands:
75101
76-
export TOKENNAME=$(kubectl get serviceaccount/host-cluster-reader -n u4a-system -o jsonpath='{.secrets[0].name}')
77-
kubectl get secret $TOKENNAME -n u4a-system -o jsonpath='{.data.token}' | base64 -d
78-
```
79-
Save the token and will use it to add the cluster later.
102+
```
103+
NOTES:
104+
1. Get the ServiceAccount token by running these commands:
105+
106+
export TOKENNAME=$(kubectl get serviceaccount/host-cluster-reader -n u4a-system -o jsonpath='{.secrets[0].name}')
107+
kubectl get secret $TOKENNAME -n u4a-system -o jsonpath='{.data.token}' | base64 -d
108+
```
109+
110+
Save the token and will use it to add the cluster later.
111+
80112
81113
4. Open the host configured using ingress below:
82114
83-
`https://portal.<replaced-ingress-nginx-ip>.nip.io`
115+
`https://portal.<replaced-ingress-nginx-ip>.nip.io`
116+
117+
118+
If your host isn't able to access nip.io, you should add the ip<->host mapping to your hosts file. Login with user admin/baas-admin (default one).
84119
85-
If your host isn't able to access nip.io, you should add the ip<->host mapping to your hosts file. Login with user admin/baas-admin (default one).
86120
87121
5. Prepare the environment
88122
1) Create a namespace for cluster management, it should be 'cluster-system'.
89-
```
90-
kubectl create -n cluster-system
91-
```
123+
124+
```
125+
kubectl create -n cluster-system
126+
```
92127
93128
2) Add current cluster to the portal. Navigate to '集群管理' and '添加集群'
94129
* for API Host, use the one from `hostK8sApiWithOidc`
95130
* for API Token, use the one you saved from step 3.
96131
97132
Now, you should have a cluster and a 'system-tenant' and tenant management.
98133
99-
## 2. Install baas-component
134+
### 2. Install baas-component
135+
136+
#### 2.1 Install Fabric-Operator and bc-api using Helm
137+
138+
1. Create namespace
139+
140+
If you want to install operator under the namespace `baas-system`, and this namespace does not exist, you need to create this namespace.
141+
142+
```shell
143+
kubectl create ns baas-system
144+
```
145+
146+
2. Install Fabric-Operator And bc-apis
147+
148+
Before installation, the content to be replaced needs to be updated.
149+
- \<replaced-ingress-nginx-ip\>
150+
- \<replaced-iam-server\>
151+
- \<replace-with-k8s-oidc-proxy-url\>
152+
- \<replace-with-oidc-server-url\>
153+
- \<replace-with-oidc-client-id\>
154+
- \<replace-with-oidc-client-secret\>
155+
156+
```shell
157+
$ cd installer;
158+
$ helm -nbaas-system install fabric fabric-operator;
159+
```
160+
For more configuration parameters, please refer to the following document: [install-fabric-operator](./fabric-operator/README.md)
161+
162+
3. Verify pods are running properly.
163+
164+
```shell
165+
$ kubectl get po -nbaas-system
166+
NAME READY STATUS RESTARTS AGE
167+
bff-apis-5b857f6577-c6pjz 1/1 Running 0 55s
168+
controller-manager-5d6449b864-ckf25 1/1 Running 0 55s
169+
```
170+
171+
4. Clean up the deployment environment
172+
```shell
173+
helm -nbaas-system uninstall fabric;
100174
175+
kubectl delete ns baas-system;
176+
```
101177
102-
## 3. Add more components
178+
### 3. Add more components
103179
1. Install [kube-dashboard](./kube-dashboard/) to integrate with u4a.
104180
105-
Refer to [kubernetes dashboard ](https://github.com/kubernetes/dashboard) for details.
181+
Refer to [kubernetes dashboard ](https://github.com/kubernetes/dashboard) for details.
106182
107183
2. Install [kubelogin](./kubelogin/) to integrate with u4a
108184
109-
Refer to [kubelogin](https://github.com/int128/kubelogin) for details.
185+
Refer to [kubelogin](https://github.com/int128/kubelogin) for details.

fabric-operator/Chart.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: v2
2+
name: fabric-operator
3+
description: fabric-operator is an open-source, cloud-native Operator for managing Hyperledger Fabric networks on Kubernetes
4+
type: application
5+
version: 0.1.0
6+
icon: https://avatars.githubusercontent.com/u/116370569?s=200&v=4
7+
appVersion: v0.1.0
8+
keywords:
9+
- chain
10+
- operator
11+
- fabric-operator
12+
- bestchains
13+
sources:
14+
- https://github.com/bestchains/fabric-operator
15+
maintainers:
16+
- name: nkwangleiGIT
17+
url: https://github.com/nkwangleiGIT
18+
- name: bjwswang
19+
url: https://github.com/bjwswang
20+
- name: Abirdcfly
21+
url: https://github.com/Abirdcfly
22+
- name: 0xff-dev
23+
url: https://github.com/0xff-dev

fabric-operator/README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Baas Helm Chart
2+
3+
## Installation
4+
5+
Quick start to deploy Baas using Helm.
6+
7+
### Prerequisites
8+
9+
- [Helm](https://helm.sh/docs/intro/quickstart/#install-helm)
10+
11+
#### Install chart using Helm v3.0+
12+
13+
1. Get source code
14+
15+
```shell
16+
$ git clone https://github.com/bestchains/installer.git;
17+
$ cd installer;
18+
```
19+
20+
2. Some variables that must be modified
21+
22+
23+
- `<replaced-ingress-nginx-ip>` needs to be replaced with the ip address of ingress
24+
- `<replaced-iam-server>` needs to be replaced with iam server address. example: https://oidc-server.system.svc
25+
- `<replace-with-k8s-oidc-proxy-url>`
26+
- `<replace-with-oidc-server-url>`
27+
- `<replace-with-oidc-client-id>`
28+
- `<replace-with-oidc-client-secret>`
29+
30+
31+
```shell
32+
# If namespace does not exist.
33+
$ kubectl create ns baas-system;
34+
$ helm -nbaas-system install fabric fabric-operator;
35+
```
36+
37+
#### Verify pods are running properly.
38+
39+
```shell
40+
$ kubectl get po -nbaas-system
41+
NAME READY STATUS RESTARTS AGE
42+
bff-apis-5b857f6577-c6pjz 1/1 Running 0 55s
43+
controller-manager-5d6449b864-ckf25 1/1 Running 0 55s
44+
```
45+
46+
### Configuration
47+
48+
The following table lists the configurable parameters of fabric-operator chart and their default values.
49+
50+
| Parameter | Description | Default |
51+
| ------------------------------------------- | ------------------------------------------- | ---------------------------------------------------------------- |
52+
| `namespace` | which namespace the operator will be deployed. | default `baas-system`. |
53+
| `ingressDomain` | ingress domain. | default `empty`, **you must set it**. |
54+
| `serviceAccountName` | service account name | default ` operator-controller-manager` |
55+
| `operator.watchNamespace` | The namespace under which the CR is created can trigger the operator's logic. | default `empty`, means all namespace. |
56+
| `operator.clusterType` | K8S, or OPENSHIFT. | default `K8S`. |
57+
| `operator.iamServer` | iam provider address. | default `emtpy`, **you must set it**. |
58+
| `operator.image` | The image that the operator deployment will use. | default `hyperledgerk8s/fabric-operator:latest` |
59+
| `operator.imagePullPolicy` | image pull policy. | default `IfNotPresent`. Other optional values for reference [image pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) |
60+
| `operator.clusterRoleName` | cluster role name. | The clusterrole contains the permissions required by the operator's serviceaccount. default `manager-role` |
61+
| `operator.clusterRoleBindingName` | cluster role binding | default `operator` |
62+
| `operator.resources` | request resource. | default request cpu is `100m`, default request memory is `200Mi` |
63+
| `operator.readinessProbe` | readiness probe | |
64+
| `operator.tolerations` | Pod tolerated stains | Tolerate all stains by default |
65+
| `operator.affinity` | How pods are scheduled | |
66+
| `leaderElection.roleName` | The name of the role that contains the permissions needed for operator elections | default `leader-election-role` |
67+
| `leaderElection.roleNameBinding` | role binding | default `leader-election-rolebinding` |
68+
| `authProxy.authProxyServiceName` | service name | default `controller-manager-metrics-service` |
69+
| `authProxy.proxyClusterRoleName` | cluster role name | default `proxy-role` |
70+
| `authProxy.proxyClusterRoleBindingName` | cluster rolebinding name | default `proxy-rolebinding` |
71+
| `authProxy.metricReaderClusterRoleName` | metrics reader cluster role name | default `metrics-reader` |
72+
| `bcapi.name` | Composited APIs for fabric resource APIs | default `bff-apis` |
73+
| `bcapi.env.k8sOIDCProxyURL` | oidc proxy url | it can be emtpty if you don't need oidc-proxy. |
74+
| `bcapi.env.OIDCServerURL` | oidc server | must be completed |
75+
| `bcapi.env.OIDCServerClientID` | oidc client id | must be completed |
76+
| `bcapi.env.OIDCServerClientSecret` | oidc client secret | must be completed |
77+
| `bcapi.image` | image used by the bff service | hyperledgerk8s/bc-apis:v0.1.0-20230118 |
78+
| `bcapi.imagePullPolicy` | the policy of pulling image | `IfNotPresent` |
79+
| `bcapi.hostAliases` | add entry to Pod's /etc/hosts | can be empty, format reference [adding-additional-entries-with-hostaliases](https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/#adding-additional-entries-with-hostaliases) |
80+
| `bcapi.ingressName` | name of the ingress of the bff service| `bc-apis-ingress` |

0 commit comments

Comments
 (0)