-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(proto): adding working envoy proxy config
- Loading branch information
Showing
28 changed files
with
678 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Deployment | ||
|
||
deploying with **Kustomize** | ||
|
||
|
||
|
||
## Reference | ||
|
||
1. <https://github.com/kubernetes-sigs/kustomize/blob/master/docs/glossary.md> | ||
2. <https://blog.jetstack.io/blog/kustomize-cert-manager/> | ||
3. <https://kustomize.io/> | ||
4. with sops <https://teuto.net/deploying-jupyterhub-to-kubernetes-via-kustomize-using-sops-secret-management/?lang=en> | ||
5. <https://github.com/pwittrock-me/petclinic-config/tree/master/config> | ||
6. [TODO: gRPC-Web Istio Demo](https://github.com/venilnoronha/grpc-web-istio-demo) | ||
7. patch example, keycloak traefik <https://github.com/piotrjanik/opa-warsaw-cloud-native-conf/tree/master/manifests> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# envoy | ||
|
||
### Prerequisite | ||
|
||
```bash | ||
wget -O ~/Downloads/protoc-gen-grpc-web https://github.com/grpc/grpc-web/releases/download/1.0.7/protoc-gen-grpc-web-1.0.7-darwin-x86_64 | ||
chmod +x ~/Downloads/protoc-gen-grpc-web | ||
mv ~/Downloads/protoc-gen-grpc-web /usr/local/bin/protoc-gen-grpc-web | ||
|
||
yarn global add grpc-tools | ||
``` | ||
|
||
### Reference | ||
|
||
```bash | ||
# minikube mount /Users/schintha/Developer/Work:/Work | ||
docker-compose up envoy | ||
|
||
|
||
docker run -it --rm --name envoy \ | ||
-p 9090:9090 -p 9901:9901 \ | ||
-v "$(pwd)/deploy/bases/envoy/envoy.yaml:/etc/envoy/envoy.yaml:ro" \ | ||
envoyproxy/envoy:latest | ||
|
||
docker exec -it envoy /bin/bash | ||
|
||
# admin http://localhost:9901/ | ||
|
||
curl 'http://localhost:9090/greetersrv/Greeter.Hello' \ | ||
-H 'Content-Type: application/grpc-web+proto' \ | ||
-H 'X-Grpc-Web: 1' \ | ||
-H 'custom-header-1: value1' \ | ||
-H 'Accept: */*' \ | ||
-H 'Connection: keep-alive' \ | ||
--data-binary $'\x00\x00\x00\x00\x05\n\x03abc' --compressed | ||
|
||
curl 'http://localhost:9090/yeti.EchoService/Echo' \ | ||
-H 'Accept: application/grpc-web-text' \ | ||
-H 'Content-Type: application/grpc-web-text' \ | ||
-H 'X-Grpc-Web: 1' \ | ||
-H 'Connection: keep-alive' \ | ||
-H 'Accept-Encoding: gzip, deflate, br' \ | ||
--data-binary 'AAAAAAYKBHN1bW8=' --compressed | ||
|
||
|
||
``` | ||
|
||
1. https://github.com/jrockway/jrock.us/blob/master/ingress/envoy.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: envoy | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: envoy | ||
image: envoyproxy/envoy:latest | ||
command: | ||
- "envoy" | ||
args: | ||
- "-c" | ||
- "/etc/envoy/envoy.yaml" | ||
volumeMounts: | ||
- name: envoy-config | ||
mountPath: /etc/envoy | ||
readinessProbe: | ||
httpGet: | ||
path: /server_info | ||
port: 9901 | ||
livenessProbe: | ||
httpGet: | ||
path: /server_info | ||
port: 9901 | ||
ports: | ||
- name: envoy-admin | ||
containerPort: 9901 | ||
- name: http | ||
containerPort: 9090 | ||
- name: https | ||
containerPort: 9443 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
commonLabels: | ||
app.kubernetes.io/name: envoy | ||
app.kubernetes.io/instance: envoy-abcxzy | ||
app.kubernetes.io/component: infra | ||
app.kubernetes.io/part-of: micro-starter-kit | ||
app.kubernetes.io/managed-by: kustomize | ||
commonAnnotations: | ||
org: acmeCorporation | ||
|
||
resources: | ||
- deployment.yaml | ||
|
||
configMapGenerator: | ||
- name: envoy-config | ||
files: ["envoy.yaml"] | ||
|
||
vars: | ||
- name: ENVOY_SRV_ENDPOINT | ||
objref: | ||
kind: EtcdCluster | ||
name: etcd-cluster | ||
apiVersion: etcd.database.coreos.com/v1beta2 | ||
fieldref: | ||
fieldpath: metadata.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: envoy | ||
annotations: | ||
service.beta.kubernetes.io/do-loadbalancer-protocol: "tcp" | ||
service.beta.kubernetes.io/do-loadbalancer-enable-proxy-protocol: "true" | ||
spec: | ||
type: LoadBalancer | ||
# We want the servers to become available even if they're not ready | ||
publishNotReadyAddresses: true | ||
ports: | ||
- name: grpc-web | ||
port: 9090 | ||
protocol: TCP | ||
targetPort: envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
commonLabels: | ||
app.kubernetes.io/name: postgres | ||
app.kubernetes.io/instance: postgres-abcxzy | ||
app.kubernetes.io/component: database | ||
|
||
resources: | ||
- postgres.yaml | ||
- service.yaml | ||
|
||
secretGenerator: | ||
- name: postgres-secrets | ||
literals: | ||
- postgres-password=postgres123 | ||
|
||
# labels for generated secrets at this level | ||
generatorOptions: | ||
labels: | ||
app.kubernetes.io/name: postgres-secrets | ||
app.kubernetes.io/instance: postgres-secrets-abcxzy | ||
app.kubernetes.io/component: secrets | ||
|
||
vars: | ||
- name: DATABASE_ENDPOINT | ||
objref: | ||
kind: Service | ||
name: postgres | ||
apiVersion: v1 | ||
fieldref: | ||
fieldpath: metadata.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: postgres | ||
labels: | ||
app: postgres | ||
spec: | ||
replicas: 1 | ||
serviceName: postgres-internal | ||
selector: | ||
matchLabels: | ||
app: postgres | ||
template: | ||
metadata: | ||
labels: | ||
app: postgres | ||
spec: | ||
terminationGracePeriodSeconds: 0 | ||
containers: | ||
- name: postgres | ||
image: postgres:11.5-alpine | ||
imagePullPolicy: Always | ||
ports: | ||
- name: tcp-pg | ||
containerPort: 5432 | ||
protocol: TCP | ||
env: | ||
- name: POSTGRES_DB | ||
value: postgres | ||
- name: POSTGRES_USER | ||
value: postgres | ||
- name: POSTGRES_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: postgres-secrets | ||
key: postgres-password | ||
livenessProbe: | ||
exec: | ||
command: ["pg_isready", "-U", "$(POSTGRES_USER)"] | ||
initialDelaySeconds: 3 | ||
timeoutSeconds: 2 | ||
readinessProbe: | ||
exec: | ||
command: ["pg_isready", "-U", "$(POSTGRES_USER)"] | ||
initialDelaySeconds: 3 | ||
timeoutSeconds: 2 | ||
volumeMounts: | ||
- name: database-storage | ||
mountPath: /var/lib/postgresql/data | ||
volumeClaimTemplates: | ||
- metadata: | ||
name: postgres-storage | ||
labels: | ||
app: postgres | ||
spec: | ||
accessModes: ["ReadWriteOnce"] | ||
# storageClassName: <custom storage class> | ||
resources: | ||
requests: | ||
storage: 1Gi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -u | ||
|
||
function create_user_and_database() { | ||
local database=$1 | ||
local username=$2 | ||
local password=$3 | ||
echo " Creating user '$username' and database '$database'" | ||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL | ||
CREATE ROLE $username WITH PASSWORD '$password' NOSUPERUSER LOGIN; | ||
CREATE DATABASE $database; | ||
GRANT ALL PRIVILEGES ON DATABASE $database TO $username; | ||
EOSQL | ||
} | ||
|
||
if [ -n "$KEYCLOAK_DB" ]; then | ||
create_user_and_database $KEYCLOAK_DB $KEYCLOAK_DB_USER $KEYCLOAK_DB_PASSWORD | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -u | ||
|
||
function create_extension() { | ||
local database=$1 | ||
echo " Creating uuid-ossp extension" | ||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL | ||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; | ||
EOSQL | ||
} | ||
|
||
if [ -n "$POSTGRES_DB" ]; then | ||
create_extension $POSTGRES_DB | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: postgres-headless | ||
labels: | ||
app: postgres | ||
spec: | ||
type: ClusterIP | ||
clusterIP: None | ||
ports: | ||
- name: tcp-pg | ||
port: 5432 | ||
targetPort: tcp-pg | ||
selector: | ||
app: postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: postgres | ||
labels: | ||
app: postgres | ||
spec: | ||
type: NodePort | ||
ports: | ||
- name: tcp-pg | ||
port: 5432 | ||
targetPort: tcp-pg | ||
nodePort: 31432 | ||
selector: | ||
app: postgres | ||
role: master |
Oops, something went wrong.