-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add authentication policy on deployer
- Loading branch information
1 parent
0dfb492
commit 660e8e5
Showing
9 changed files
with
194 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ You must have a real domain name (not xip.io auto-domain) to enable HTTPS. | |
The helper script enables HTTPS using [CloudDNS](#), [Let's Encrypt](#) and [cert-manager](#). Adapt the ClusterIssuer manifest if you are using a different DNS. | ||
|
||
```bash | ||
export KUDA_PROJECT_ID=your-gcp-project | ||
export KUDA_GCP_PROJECT=your-gcp-project | ||
export KUDA_DOMAIN=example.com | ||
export KUDA_NAMESPACE=default | ||
export [email protected] | ||
|
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
service.yaml | ||
service.yaml | ||
service-workaround.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
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,101 @@ | ||
# Workaround "native" istio service since there is an issue with Knative and | ||
# istio's policy not being applied. | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: deployer | ||
namespace: kuda | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: deployer | ||
template: | ||
metadata: | ||
labels: | ||
app: deployer | ||
spec: | ||
containers: | ||
- image: gcr.io/kuda-project/deployer | ||
name: deployer | ||
volumeMounts: | ||
- name: secret | ||
readOnly: true | ||
mountPath: "/secret" | ||
env: | ||
- name: PORT | ||
value: "80" | ||
- name: KUDA_GCP_PROJECT | ||
value: $KUDA_GCP_PROJECT | ||
- name: GOOGLE_APPLICATION_CREDENTIALS | ||
value: /secret/key.json | ||
ports: | ||
- containerPort: 80 | ||
volumes: | ||
- name: secret | ||
secret: | ||
secretName: deployer-credentials | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: deployer | ||
namespace: kuda | ||
spec: | ||
ports: | ||
- name: http | ||
port: 80 | ||
targetPort: 80 | ||
selector: | ||
app: deployer | ||
--- | ||
apiVersion: networking.istio.io/v1alpha3 | ||
kind: VirtualService | ||
metadata: | ||
name: deployer-vservice | ||
namespace: kuda | ||
spec: | ||
hosts: | ||
- deployer.kuda | ||
- deployer.kuda.$KUDA_DOMAIN | ||
- deployer.kuda.svc | ||
- deployer.kuda.svc.cluster.local | ||
gateways: | ||
- deployer-gw | ||
http: | ||
- route: | ||
- destination: | ||
host: deployer | ||
port: | ||
number: 80 | ||
--- | ||
apiVersion: networking.istio.io/v1alpha3 | ||
kind: Gateway | ||
metadata: | ||
name: deployer-gw | ||
namespace: kuda | ||
spec: | ||
selector: | ||
istio: ingressgateway | ||
servers: | ||
- port: | ||
number: 80 | ||
name: http | ||
protocol: HTTP | ||
hosts: | ||
- deployer.kuda | ||
- deployer.kuda.$KUDA_DOMAIN | ||
- deployer.kuda.svc | ||
- deployer.kuda.svc.cluster.local | ||
- port: | ||
number: 443 | ||
name: https | ||
protocol: HTTPS | ||
tls: | ||
mode: SIMPLE | ||
privateKey: /etc/istio/ingressgateway-certs/tls.key | ||
serverCertificate: /etc/istio/ingressgateway-certs/tls.crt | ||
hosts: | ||
- deployer.kuda | ||
- deployer.kuda.$KUDA_DOMAIN | ||
- deployer.kuda.svc | ||
- deployer.kuda.svc.cluster.local |
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,50 @@ | ||
#!/bin/bash | ||
|
||
# Make sure you've configured the auth module before running this script | ||
# otherwise you won't be able to the access services in the kuda namespace. | ||
|
||
set -e | ||
|
||
source "$(dirname $BASH_SOURCE)/utils.sh" | ||
|
||
# If using Firebase / Cloud Identity as authentication provider. | ||
FIREBASE_JWT_ISSUER="https://securetoken.google.com/$KUDA_GCP_PROJECT" | ||
FIREBASE_JWT_URI="https://www.googleapis.com/service_accounts/v1/jwk/[email protected]" | ||
|
||
export KUDA_JWT_ISSUER="${KUDA_JWT_ISSUER:-$FIREBASE_JWT_ISSUER}" | ||
export KUDA_JWT_URI="${KUDA_JWT_URI:-$FIREBASE_JWT_URI}" | ||
|
||
assert_set KUDA_GCP_PROJECT $KUDA_GCP_PROJECT | ||
assert_set KUDA_JWT_ISSUER $KUDA_JWT_ISSUER | ||
assert_set KUDA_JWT_URI $KUDA_JWT_URI | ||
|
||
function setup_deployer_auth_policy() { | ||
echo "Adding istio authentication policy for deployer..." | ||
|
||
kubectl apply -f - <<EOF | ||
apiVersion: authentication.istio.io/v1alpha1 | ||
kind: Policy | ||
metadata: | ||
name: deployer-origin-auth | ||
namespace: kuda | ||
spec: | ||
targets: | ||
- name: deployer | ||
ports: | ||
- number: 80 | ||
- number: 443 | ||
origins: | ||
- jwt: | ||
issuer: $KUDA_JWT_ISSUER | ||
audiences: | ||
- "$KUDA_GCP_PROJECT" | ||
jwksUri: "$KUDA_JWT_URI" | ||
triggerRules: | ||
- excluded_paths: | ||
- prefix: /metrics | ||
- prefix: /healthz | ||
principalBinding: USE_ORIGIN | ||
EOF | ||
} | ||
|
||
setup_deployer_auth_policy |
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,20 @@ | ||
bold="\033[1m" | ||
blue="\e[36m" | ||
green="\033[32m" | ||
red="\033[31m" | ||
reset="\033[0m" | ||
|
||
function error() { | ||
printf "${red}ERROR:${reset} $1\n" | ||
} | ||
|
||
function assert_set() { | ||
var_name=$1 | ||
var_value=$2 | ||
if [ -z "$var_value" ]; then | ||
error "Missing required env variable $var_name" | ||
exit 1 | ||
else | ||
printf "$var_name: ${blue}$var_value${reset}\n" | ||
fi | ||
} |