https://github.com/skshahriarahmedraka/simple-grpc-server-with-openfaas
https://github.com/skshahriarahmedraka/simple-grpc-server-with-openfaas
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/skshahriarahmedraka/simple-grpc-server-with-openfaas
- Owner: skshahriarahmedraka
- Created: 2023-07-19T11:36:44.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-07-26T05:14:25.000Z (almost 2 years ago)
- Last Synced: 2025-01-19T18:45:32.080Z (4 months ago)
- Language: Go
- Size: 2.96 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### NOTE: Openfaas Doesn't support Grpc protocol yet
### protoc installation (Protocol Buffer Compiler)
For Linux :
```
sudo apt install -y protobuf-compiler
```### protoc-gen-go (the code generator) installation
We need to generate the server’s code and the messages’ encoding.
To do that, we will need a code generator :
```
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
``````
sudo apt install golang-goprotobuf-dev
```### First locally test client and server
run server
```
go run server/main.go
```run client
```
go run client/main.go
```# Method 1 : Using Docker
1. build docker image of server
inside `/server`
```
sudo docker build -t shahriarraka/simple-grpc .
```2. push the contianer to docker hub
```
sudo docker push shahriarraka/simple-grpc:latest
```3. create a deployment file for openfaas

4. see the log
# Method 2: using Openfaas template
### built a github package (grpc-server) for running there server
```
https://github.com/skshahriarahmedraka/grpc-server
```## Run OpenFass using this instructions
```
https://mickey.dev/posts/getting-started-with-openfaas/
```## build the function for deploying openfaas
1. created a deploy server config file (simple-openfass-func.yml) for openfaas
2. build the function using this command
```
sudo faas-cli new --lang go server
```3. build the deployment file using this command
```
sudo faas-cli build -f simple-openfaas-func.yml
```4. push the docker image to docker hub using this command
```
sudo faas-cli push -f simple-openfaas-func.yml
```5. login to openfaas using this command
```
export PASSWORD=mysecretpassword
echo -n $PASSWORD | faas-cli login --username admin --password-stdin --gateway 127.0.0.1:31112
```6. deploy the function using this command
```
sudo faas-cli deploy -f simple-openfaas-func.yml --gateway 127.0.0.1:31112
```






For reference :
https://www.openfaas.com/blog/golang-deep-dive/
https://gcore.com/learning/create-serverless-functions-with-openfaas/
https://mickey.dev/posts/getting-started-with-openfaas/
https://docs.openfaas.com/cli/templates/