Giter VIP home page Giter VIP logo

ssl_grpc_example's Introduction

Sample Python gRPC test for OpenShift

Certificate

Generate certificate for the server. Uses openssl.

For the CN, use the *.apps.apps.<cluster_name>.<base_domain> wildcard hostname for OpenShift:

$ oc get ingresses.config/cluster -o jsonpath='{.spec.domain}'
apps.cluster-d3f6.d3f6.example.opentlc.com
make gen_key

Enable http/2

$ oc annotate ingresses.config/cluster ingress.operator.openshift.io/default-enable-http2=true

Create Server

You can either build the image using S2I or deploy a prebuilt image from quay.io

$ oc new-app https://github.com/tsailiming/ssl_grpc_example --name grpc
$ oc new-app --docker-image=quay.io/ltsai/python-grpc-demo --name=grpc

Configure TLS and expose route:

$ oc create secret tls tls-secret --cert=tls/tls.crt --key=tls/tls.key 
$ oc set volume dc/grpc --name=tls-secret --type=secret --secret-name=tls-secret --mount-path=/opt/app-root/src/tls --add
$ oc create route passthrough grpc --service=grpc

Run Client

Using gRPCurl:

$ HOSTNAME=`oc get route grpc -o jsonpath='{.spec.host}'`
$ grpcurl  -import-path . -proto service.proto -insecure -cert tls/tls.crt -key tls/tls.key $HOSTNAME:443 Server.Foo
{
  "message": "Hello! Current time is Thu Sep 24 14:47:30 2020"
}

Credit

This repository was originally from http://www.sandtable.com/using-ssl-with-grpc-in-python/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.