Skip to content

Commit

Permalink
doc: edit doc for openfaas setup
Browse files Browse the repository at this point in the history
Signed-off-by: Amir Movahedi <[email protected]>
  • Loading branch information
Qolzam committed Feb 19, 2021
1 parent 86ed00a commit 3461166
Show file tree
Hide file tree
Showing 29 changed files with 147 additions and 148 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
### Download
- [Linux](https://github.com/Qolzam/telar-cli/releases/download/v0.1.0/telar)
- [Mac](https://github.com/Qolzam/telar-cli/releases/download/v0.1.0/telar-darwin)
- [Windows](https://github.com/Qolzam/telar-cli/releases/download/v0.1.0/telar.exe)


### Setup Options
Expand Down
Binary file modified bin/telar
Binary file not shown.
Binary file modified bin/telar-darwin
Binary file not shown.
10 changes: 5 additions & 5 deletions cmd/ofcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func OFCAccessSetting() {
echoStep(2)
}
func CheckIngredient(projectPath string, githubUsername string) {
helpURL := "https://github.com/Qolzam/telar-cli/blob/master/docs/ofcc-setup/2.md"
helpURL := "https://github.com/Qolzam/telar-cli/blob/master/docs/ofcc-setup/3.md"
echoInput("loadingCheckIngredients", true)

// Check telar-web repository
Expand Down Expand Up @@ -216,7 +216,7 @@ func CheckIngredient(projectPath string, githubUsername string) {
}

func CheckStorage(projectPath string, bucketName string) {
helpURL := "https://github.com/Qolzam/telar-cli/blob/master/docs/ofcc-setup/3.md"
helpURL := "https://github.com/Qolzam/telar-cli/blob/master/docs/ofcc-setup/4.md"
echoInput("loadingFirebaseStorage", true)

// Check serviceAccount.json file for Firebase
Expand Down Expand Up @@ -244,7 +244,7 @@ func CheckStorage(projectPath string, bucketName string) {
}

func CheckDatabase(mongoDBHost, MongoDBPassword string) {
helpURL := "https://github.com/Qolzam/telar-cli/blob/master/docs/ofcc-setup/4.md"
helpURL := "https://github.com/Qolzam/telar-cli/blob/master/docs/ofcc-setup/5.md"

echoInput("loadingMongoDB", true)

Expand All @@ -270,7 +270,7 @@ func CheckOAuth() {
}

func CheckUserManagement(ofGateway string) {
helpURL := "https://github.com/Qolzam/telar-cli/blob/master/docs/ofcc-setup/7.md"
helpURL := "https://github.com/Qolzam/telar-cli/blob/master/docs/ofcc-setup/8.md"

payloadSecret, err := generatePayloadSecret()
if isError(err) {
Expand All @@ -284,7 +284,7 @@ func CheckUserManagement(ofGateway string) {
}

func CheckWebsocket(clientInput ClientInputs) {
helpURL := "https://github.com/Qolzam/telar-cli/blob/master/docs/ofcc-setup/8.md"
helpURL := "https://github.com/Qolzam/telar-cli/blob/master/docs/ofcc-setup/9.md"
echoInput("loadingWebsocket", true)

err := pingWebsocket(clientInput.WebsocketURL)
Expand Down
14 changes: 3 additions & 11 deletions docs/ofcc-setup/1.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
# Telar CLI - Setup Telar Social on OpenFaaS (Free Tire)
# Telar CLI - Setup Telar Social on OpenFaaS

## Step 1 (Let's start)

### 1. Enter your valid Github username
### 1. Enter the project directory path

Register you Github account on OpenFaaS [from here](https://github.com/openfaas/community-cluster#apply-for-access).
> OpenFaaS introduces an automated build and management system for your Serverless functions with native integrations into your source-control management system whether that is GitHub or GitLab. With OpenFaaS functions are managed through typing `git push` which reduces the tooling and learning curve required to operate functions for your team. As soon as OpenFaaS receives a push event from `git` it will run through a build-workflow which clones your repo, builds a Docker image, pushes it to a registry and then deploys your functions to your cluster.
We use Github to manage Telar Social source code and get advantage of automates CI/CD triggered by `git push`.


### 2. Enter the project directory path

Telar CLI will clone all Telar Social source code inside this directory.
Telar CLI will clone all Telar Social source code inside this directory and create some files which are required for installation.
35 changes: 18 additions & 17 deletions docs/ofcc-setup/2.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
# Telar CLI - Setup Telar Social on OpenFaaS (Free Tire)
# Telar CLI - Setup Telar Social on OpenFaaS

## Step 2 (Check ingredients)
## Step 2 (General settings)

### 1. The OpenFaaS Github app is installed
### 1. Enter your social network app ID

Following [document](https://github.com/openfaas/community-cluster#2-after-you-receive-your-confirmation-email) after you receive your confirmation email to access OpenFaaS , you should Send your PR to the [CUSTOMERS](https://github.com/openfaas/openfaas-cloud/blob/master/CUSTOMERS) file. Then you need to install [OpenFaaS Github app](https://github.com/apps/openfaas-cloud-community-cluster).
We use this identifier to detect social network functions in the cluster.

### 2. Add repositories in the OpenFaaS Github app
### 2. Enter OpenFaaS username. Default is `admin`.

- Make sure you already foked [telar-web](https://github.com/red-gold/telar-web), [ts-serverless](https://github.com/red-gold/ts-serverless) and [ts-ui](https://github.com/red-gold/ts-ui).
We use OpenFaaS username to login with to handle some OpenFaaS functionalities like delete or deploy function.

![Fork Example](https://miro.medium.com/max/3155/1*R4YdE6yz_HLVVW9DK8nWMQ.png)
### 3. Enter OpenFaaS gateway e.g. `domain.com` or `localhost.com:31112`

- From Github page, in the upper-right corner of any page, click your profile photo, then click Settings.

![Github Setting](https://help.github.com/assets/images/help/settings/userbar-account-settings.png)
This is the [OpenFaaS gateway](https://docs.openfaas.com/architecture/gateway/) address to interact with OpenFaaS.

- From Github Application/Installed Github Apps menu click on OpenFaaS `Configure`.
### 4. Enter your social network URL e.g. https://social.com

![Github Application](https://miro.medium.com/max/2726/1*vWuo8177iw8rgXNe2V2-qw.png)
The URL can access to social network UI and api which could be different with OpenFaaS gateway.

- In Repository access select [telar-web](https://github.com/red-gold/telar-web), [ts-serverless](https://github.com/red-gold/ts-serverless) and [ts-ui](https://github.com/red-gold/ts-ui).
### 5. Enter OpenFaaS funtion namespace. Default is `openfaas-fn`

- Click on Save
Enter functions namespace, in the case your OpenFaaS functions are in different K8S namespace .

### 3. Adding SSH key to Github
### 6. Enter secret name that will be created on your K8S cluster. Default is `secrets`

- [Generating a new SSH key and adding it to the ssh-agent](https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
- [Adding a new SSH key to your GitHub account](https://help.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account)
Enter secret name that you want to create in K8S cluster for social network.

### 7. Enter your KUBECONFIG path

In the case you want to use KUBECONFIG path instead of default context, enter the kube config path. If not let the textbox empty.
21 changes: 3 additions & 18 deletions docs/ofcc-setup/3.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
# Telar CLI - Setup Telar Social on OpenFaaS (Free Tire)
# Telar CLI - Setup Telar Social on OpenFaaS

## Step 3 (Firebase Storage)
## Step 3 (Check ingredients)

- Make sure you alread have a Firebase account and project ready to use.

### 1. Copy Firebase Service Account file in your project directory

- In the Firebase console, open Settings > [Service Accounts](https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk).
![Firebase Project Settings](https://miro.medium.com/max/2812/1*snYuDB4IOOCtBv7s2dt2KQ.png)
- Click Generate New Private Key, then confirm by clicking Generate Key.
![Generate Firebase Key](https://miro.medium.com/max/2534/1*D7pVdJhsrYJllAqks6DyrQ.png)
- Change the file name to `serviceAccountKey.json`.
- Copy `serviceAccountKey.json` file in your project directory.

### 2. Enter Firebase Storage Bucket name

- [Create a default Storage bucket](https://firebase.google.com/docs/storage/web/start#create-default-bucket)
- From Firebase Storage menu you can find your bucket name.
![Bucket Name](https://raw.githubusercontent.com/Qolzam/telar-cli/master/docs/images/firebase-storage.PNG)
### 1. Click on next to chack and prepare the ingredients for installation.
38 changes: 16 additions & 22 deletions docs/ofcc-setup/4.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
# Telar CLI - Setup Telar Social on OpenFaaS (Free Tire)
# Telar CLI - Setup Telar Social on OpenFaaS

## Step 4 (MongoDB)
## Step 4 (Firebase Storage)

- [Create a MongoDB Account](https://account.mongodb.com/account/register)
- [Create a Free tire Cluster](https://docs.atlas.mongodb.com/tutorial/deploy-free-tier-cluster/)
- Make sure you alread have a Firebase account and project ready to use.

### 1. Add a New User for Database Access
- From `Database Access` menu, click on ` Add New Database User`.
![Database Access](https://github.com/Qolzam/telar-cli/blob/master/docs/images/mongo-1.PNG)
- Enter username and click on `Autogenerate secure password` then click on `Add User`.
![Autogenerate secure password](https://github.com/Qolzam/telar-cli/blob/master/docs/images/mongo-2.PNG)
- Back in the Telar CLI copy password in Telar CLI `Password` field.
### 2. Enter connection string
- From Cluster menu click on `CONNECT`.
![CONNECT](https://raw.githubusercontent.com/Qolzam/telar-cli/master/docs/images/mongo-5.PNG)
- From Connect window click on `Connect your application`. Then copy connection string using `Copy` button then back in the Telar CLI paste it in `Host` field.
> Note: The connection string should follow the pattern mongodb+srv://amir:`<password>`@cluster0-luefk.mongodb.net/test?retryWrites=true&w=majority. If you created more that one database user the connection string will change to mongodb+srv://`<username>`:`<password>`@cluster0-luefk.mongodb.net/test?retryWrites=true&w=majority. In this case you need to replace one of database username with `<username>`.
![connection string](https://github.com/Qolzam/telar-cli/blob/master/docs/images/mongo-7.PNG)
### 1. Copy Firebase Service Account file in your project directory

### 3. Enable Network Access
- From `Network Access` menu, click on `Add IP Address`.
![Add IP Address](https://raw.githubusercontent.com/Qolzam/telar-cli/master/docs/images/mongo-3.PNG)
- From the open window click on `Allow Access from Anywhere` then `Confirm`.
![Allow Access from Anywhere](https://raw.githubusercontent.com/Qolzam/telar-cli/master/docs/images/mongo-4.PNG)

- In the Firebase console, open Settings > [Service Accounts](https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk).
![Firebase Project Settings](https://miro.medium.com/max/2812/1*snYuDB4IOOCtBv7s2dt2KQ.png)
- Click Generate New Private Key, then confirm by clicking Generate Key.
![Generate Firebase Key](https://miro.medium.com/max/2534/1*D7pVdJhsrYJllAqks6DyrQ.png)
- Change the file name to `serviceAccountKey.json`.
- Copy `serviceAccountKey.json` file in your project directory.

### 2. Enter Firebase Storage Bucket name

- [Create a default Storage bucket](https://firebase.google.com/docs/storage/web/start#create-default-bucket)
- From Firebase Storage menu you can find your bucket name.
![Bucket Name](https://raw.githubusercontent.com/Qolzam/telar-cli/master/docs/images/firebase-storage.PNG)
49 changes: 26 additions & 23 deletions docs/ofcc-setup/5.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
# Telar CLI - Setup Telar Social on OpenFaaS (Free Tire)

## Step 5 ([Google reCaptcha](https://support.google.com/recaptcha/?hl=enhttps://support.google.com/recaptcha/?hl=en))

Google reCAPTCHA prompts visitors to check a box to prove that they’re not a robot before they submit their information.
To enable reCAPTCHA, you'll need a Google account. This integration uses reCAPTCHA V2.

### 1. In the site Settings panel, click Advanced, then click External API Keys.
### 2. Scroll down to Google reCAPTCHA.
### 3. Click the link to get your Google reCAPTCHA API Keys. The link will open in a new tab.
### 4. Click Admin Console, then select reCAPTCHA V2. Telar Social doesn't support reCAPTCHA V3.
### 5. Select "I'm not a robot" Checkbox. The other options aren't supported.
### 6. Enter your built-in domain and click the + icon. Use the format [your-github-username].[ofc-domain], excluding https:// from the beginning. In my case the [your-github-username] is red-gold (red-gold.cloud.telar.dev).

![reCaptcha](https://miro.medium.com/max/1839/1*QwDRyFRk7Z9i2bp-UXKc_Q.png)

### 7. Click Submit.
### 8. Copy your Site Key and Secret Key.
![The Site Key and Secret Key in the reCAPTCHA dashboard](https://raw.githubusercontent.com/Qolzam/telar-cli/master/docs/images/recaptcha.png)
### 9. Back in the Telar CLI, paste your keys.



# Telar CLI - Setup Telar Social on OpenFaaS

## Step 5 (MongoDB)

- [Create a MongoDB Account](https://account.mongodb.com/account/register)
- [Create a Free tire Cluster](https://docs.atlas.mongodb.com/tutorial/deploy-free-tier-cluster/)

### 1. Add a New User for Database Access
- From `Database Access` menu, click on ` Add New Database User`.
![Database Access](https://github.com/Qolzam/telar-cli/blob/master/docs/images/mongo-1.PNG)
- Enter username and click on `Autogenerate secure password` then click on `Add User`.
![Autogenerate secure password](https://github.com/Qolzam/telar-cli/blob/master/docs/images/mongo-2.PNG)
- Back in the Telar CLI copy password in Telar CLI `Password` field.
### 2. Enter connection string
- From Cluster menu click on `CONNECT`.
![CONNECT](https://raw.githubusercontent.com/Qolzam/telar-cli/master/docs/images/mongo-5.PNG)
- From Connect window click on `Connect your application`. Then copy connection string using `Copy` button then back in the Telar CLI paste it in `Host` field.
> Note: The connection string should follow the pattern mongodb+srv://amir:`<password>`@cluster0-luefk.mongodb.net/test?retryWrites=true&w=majority. If you created more that one database user the connection string will change to mongodb+srv://`<username>`:`<password>`@cluster0-luefk.mongodb.net/test?retryWrites=true&w=majority. In this case you need to replace one of database username with `<username>`.
![connection string](https://github.com/Qolzam/telar-cli/blob/master/docs/images/mongo-7.PNG)

### 3. Enable Network Access
- From `Network Access` menu, click on `Add IP Address`.
![Add IP Address](https://raw.githubusercontent.com/Qolzam/telar-cli/master/docs/images/mongo-3.PNG)
- From the open window click on `Allow Access from Anywhere` then `Confirm`.
![Allow Access from Anywhere](https://raw.githubusercontent.com/Qolzam/telar-cli/master/docs/images/mongo-4.PNG)

24 changes: 18 additions & 6 deletions docs/ofcc-setup/6.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
# Telar CLI - Setup Telar Social on OpenFaaS (Free Tire)
# Telar CLI - Setup Telar Social on OpenFaaS

## Step 6 (Github OAuth)
## Step 6 ([Google reCaptcha](https://support.google.com/recaptcha/?hl=enhttps://support.google.com/recaptcha/?hl=en))

Following [Github document](https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app/) register your Github OAuth application.
Google reCAPTCHA prompts visitors to check a box to prove that they’re not a robot before they submit their information.
To enable reCAPTCHA, you'll need a Google account. This integration uses reCAPTCHA V2.

### 1. In the site Settings panel, click Advanced, then click External API Keys.
### 2. Scroll down to Google reCAPTCHA.
### 3. Click the link to get your Google reCAPTCHA API Keys. The link will open in a new tab.
### 4. Click Admin Console, then select reCAPTCHA V2. Telar Social doesn't support reCAPTCHA V3.
### 5. Select "I'm not a robot" Checkbox. The other options aren't supported.
### 6. Enter your built-in domain and click the + icon. Use the format [your-github-username].[ofc-domain], excluding https:// from the beginning. In my case the [your-github-username] is red-gold (red-gold.cloud.telar.dev).

![reCaptcha](https://miro.medium.com/max/1839/1*QwDRyFRk7Z9i2bp-UXKc_Q.png)

### 7. Click Submit.
### 8. Copy your Site Key and Secret Key.
![The Site Key and Secret Key in the reCAPTCHA dashboard](https://raw.githubusercontent.com/Qolzam/telar-cli/master/docs/images/recaptcha.png)
### 9. Back in the Telar CLI, paste your keys.

### 1. Set Authorization callback URL to https://[your_github_username].[ofc-domain]/auth` in my case https://red-gold.cloud.telar.dev/auth.
![Github OAuth](https://miro.medium.com/max/1872/1*X2IEBxVNE1xs-24hjQB8uA.png)
### 2. Back in the Telar CLI, after registering Github application, enter client ID and client secret from your Github application page.


12 changes: 7 additions & 5 deletions docs/ofcc-setup/7.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Telar CLI - Setup Telar Social on OpenFaaS (Free Tire)
# Telar CLI - Setup Telar Social on OpenFaaS

## Step 7 (User Management)
## Step 7 (Github OAuth)

### 1. Enter your Telar Social admin email and password.
Following [Github document](https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app/) register your Github OAuth application.

### 1. Set Authorization callback URL to https://[your_github_username].[ofc-domain]/auth` in my case https://red-gold.cloud.telar.dev/auth.
![Github OAuth](https://miro.medium.com/max/1872/1*X2IEBxVNE1xs-24hjQB8uA.png)
### 2. Back in the Telar CLI, after registering Github application, enter client ID and client secret from your Github application page.

### 2. Enter your valid Gmail and password for sending signup/reset password verfication code to Telar Social users.

> Note: In some cases you need do some configurations to enable this feature for Gmail. Please follow [nodemailer instruction](https://nodemailer.com/usage/using-gmail/) enabling access to the email.
17 changes: 6 additions & 11 deletions docs/ofcc-setup/8.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# Telar CLI - Setup Telar Social on OpenFaaS (Free Tire)
# Telar CLI - Setup Telar Social on OpenFaaS

## Step 8 (Websocket)
We are using socket.io to handle realtime data. We provided a websocket server running on Heroku. Setup websocket server following bellow steps. We assumed you have Heroku account logged in already.
## Step 8 (User Management)

#### 1. Go to [ts-websocket](https://github.com/Qolzam/ts-websocket) repository and click on `Deploy to Heroku`.
#### 2. You will be redirected to Heroku website. Type your app name and click on Deploy app.
#### 3. Click on Manage App then click on Settings tab. Find Config Vars and click on Reveal Config Vars.
#### 4. Add following Key/Value in your app. Copy your payload secret from Telar CLI.
- [ ] Key: GATEWAY , Value: https://[your-github-username].[ofc-domain]
- [ ] Key: PAYLOAD_SECRET , Value: your_payload_secret
- [ ] Key: PRETTY_URL , Value: true
### 1. Enter your Telar Social admin email and password.

#### 5. Back in the Telar CLI, enter your Heroku websoket app URL.
### 2. Enter your valid Gmail and password for sending signup/reset password verfication code to Telar Social users.

> Note: In some cases you need do some configurations to enable this feature for Gmail. Please follow [nodemailer instruction](https://nodemailer.com/usage/using-gmail/) enabling access to the email.
14 changes: 14 additions & 0 deletions docs/ofcc-setup/9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Telar CLI - Setup Telar Social on OpenFaaS

## Step 9 (Websocket)
We are using socket.io to handle realtime data. We provided a websocket server running on Heroku. Setup websocket server following bellow steps. We assumed you have Heroku account logged in already.

#### 1. Go to [ts-websocket](https://github.com/Qolzam/ts-websocket) repository and click on `Deploy to Heroku`.
#### 2. You will be redirected to Heroku website. Type your app name and click on Deploy app.
#### 3. Click on Manage App then click on Settings tab. Find Config Vars and click on Reveal Config Vars.
#### 4. Add following Key/Value in your app. Copy your payload secret from Telar CLI.
- [ ] Key: GATEWAY , Value: https://[your-github-username].[ofc-domain]
- [ ] Key: PAYLOAD_SECRET , Value: your_payload_secret
- [ ] Key: PRETTY_URL , Value: true

#### 5. Back in the Telar CLI, enter your Heroku websoket app URL.
Loading

0 comments on commit 3461166

Please sign in to comment.