Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authorino Reconciler #1

Merged
merged 6 commits into from
Nov 17, 2021
Merged

Authorino Reconciler #1

merged 6 commits into from
Nov 17, 2021

Conversation

jjaferson
Copy link
Contributor

@jjaferson jjaferson commented Nov 1, 2021

This PR is the starting point to enable the deployment of Authorino instances via the operator.

Ps.: missing unit testing

Verification steps

  1. Clone the repo from this branch
  2. Install the operator on a cluster of your choice
  3. Run the operator eg: make install run
  4. Create an instance of authorino using the CR, an example can be found here.
  5. Check if the authorino instance was deployed correctly by verifying whether a deployment is created and a pod is up and running

main.go Outdated Show resolved Hide resolved
main.go Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@jjaferson jjaferson force-pushed the foundation2 branch 6 times, most recently from 30eef4f to 0947c36 Compare November 16, 2021 18:00
Copy link
Collaborator

@guicassolato guicassolato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with the following script:

kind create cluster --name authorino

# operator
make docker-build OPERATOR_IMAGE=authorino-operator:local
kind load docker-image authorino-operator:local --name authorino
kubectl create namespace authorino-operator
make install deploy OPERATOR_IMAGE=authorino-operator:local

kubectl create namespace myapp

# upstream
kubectl -n myapp apply -f https://raw.githubusercontent.com/Kuadrant/authorino/main/examples/talker-api/talker-api-deploy.yaml

# authorino (without tls)
kubectl -n myapp apply -f -<<EOF
apiVersion: operator.authorino.kuadrant.io/v1beta1
kind: Authorino
metadata:
  name: authorino
spec:
  replicas: 1
  clusterWide: false
  listener:
    tls:
      enabled: false
  oidcServer:
    tls:
      enabled: false
EOF

# envoy (without tls)
curl -L https://raw.githubusercontent.com/Kuadrant/authorino/main/examples/envoy/overlays/notls/configmap.yaml | sed -E 's/authorino-authorization/authorino-authorino-authorization/g' | kubectl -n myapp apply -f -
kubectl -n myapp apply -f https://raw.githubusercontent.com/Kuadrant/authorino/main/examples/envoy/base/envoy.yaml

# authconfig
kubectl -n myapp apply -f -<<EOF
apiVersion: authorino.3scale.net/v1beta1
kind: AuthConfig
metadata:
  name: talker-api-protection
spec:
  hosts:
    - talker-api
  identity:
    - name: friends
      apiKey:
        labelSelectors:
          group: friends
      credentials:
        in: authorization_header
        keySelector: APIKEY
EOF

# consume
kubectl -n myapp apply -f -<<EOF
apiVersion: v1
kind: Secret
metadata:
  name: friend-1-api-key-1
  labels:
    authorino.3scale.net/managed-by: authorino
    group: friends
stringData:
  api_key: ndyBzreUzF4zqDQsqSPMHkRhriEOtcRx
type: Opaque
EOF

kubectl -n myapp port-forward deployment/envoy 8000:8000 &
curl -H 'Host: talker-api' -H 'Authorization: APIKEY ndyBzreUzF4zqDQsqSPMHkRhriEOtcRx' http://localhost:8000/hello

# tls certs
CURRENT_DIR=$PWD; AUTHORINO_DIR=$(mktemp -d); cd $AUTHORINO_DIR
git clone --depth 1 --branch main https://github.com/kuadrant/authorino.git && cd authorino
make cert-manager
make certs AUTHORINO_NAMESPACE=myapp
rm -rf $AUTHORINO_DIR; cd $CURRENT_DIR

# authorino (with tls)
kubectl -n myapp apply -f -<<EOF
apiVersion: operator.authorino.kuadrant.io/v1beta1
kind: Authorino
metadata:
  name: authorino
spec:
  replicas: 1
  clusterWide: false
  listener:
    tls:
      certSecretRef:
        name: authorino-server-cert
  oidcServer:
    tls:
      certSecretRef:
        name: authorino-oidc-server-cert
EOF

# envoy (with tls)
curl -L https://raw.githubusercontent.com/Kuadrant/authorino/main/examples/envoy/overlays/tls/configmap.yaml | sed -E 's/authorino-authorization/authorino-authorino-authorization/g' | kubectl -n myapp apply -f -
kubectl -n myapp apply -f https://raw.githubusercontent.com/Kuadrant/authorino/main/examples/envoy/base/envoy.yaml
kubectl -n myapp patch deployment/envoy -p '{"spec":{"template":{"spec":{"volumes":[{"name":"authorino-ca-cert","secret":{"defaultMode":420,"secretName":"authorino-ca-cert"}}],"containers":[{"name":"envoy","volumeMounts":[{"name":"authorino-ca-cert","subPath":"ca.crt","mountPath":"/etc/ssl/certs/authorino-ca-cert.crt","readOnly":true}]}]}}}}'

# consume
curl -H 'Host: talker-api' -H 'Authorization: APIKEY ndyBzreUzF4zqDQsqSPMHkRhriEOtcRx' http://localhost:8000/hello

# cleanup
kind delete cluster --name authorino

Works perfectly! Congratz and thank you, @jjaferson!

* Installs authorino CRDs and Clusterroles via manifest
Copy link
Contributor

@eguzki eguzki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job 🎖️

@jjaferson jjaferson merged commit 4c757ba into main Nov 17, 2021
@guicassolato guicassolato mentioned this pull request Nov 17, 2021
@jjaferson jjaferson deleted the foundation2 branch January 18, 2022 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants