The IBM Application Gateway can be deployed in Kubernetes alongside an application using the sidecar pattern. This allows an application developer with limited or no understanding of the IBM Application Gateway configuration to add a predefined set of annotations to the application deployment YAML to create the required sidecar container.
Note: It is assumed that the IBM Application Gateway operator has already been installed into the environment and is available.
The following steps will:
- Create an application that will be fronted by IBM Application Gateway
- Access the application via the IBM Application Gateway
- The page will show the identity and other headers that have been added to the request by the IBM Application Gateway
This example does not include authentication. This example illustrates the deployment process for using IBM Application Gateway as a proxy to a protected application.
- Paste the following into a file named test_config.yaml.
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config
data:
config: |
version: "22.07"
resource_servers:
- path: /demo-local
connection_type: tcp
servers:
- host: 127.0.0.1
port: 8000
identity_headers:
attributes:
- attribute: AZN_CRED_AUTHNMECH_INFO
header: mech_info
- attribute: AZN_CRED_REGISTRY_ID
jwt:
certificate: |
-----BEGIN CERTIFICATE-----
MIIDSzCCAjOgAwIBAgIUFeqbJIDD0ITJN12OXKLNR9FaLaYwDQYJKoZIhvcNAQEL
BQAwNTELMAkGA1UEBhMCdXMxDDAKBgNVBAoMA2libTEYMBYGA1UEAwwPd3d3Lmlh
Z2RlbW8uY29tMB4XDTIwMDUxNTAwMDQyOVoXDTIxMDUxNTAwMDQyOVowNTELMAkG
A1UEBhMCdXMxDDAKBgNVBAoMA2libTEYMBYGA1UEAwwPd3d3LmlhZ2RlbW8uY29t
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAssbA0VB0WTikufBOVaUC
tIDyVQ9tknM7yxVg+pJc7zA/nVWvNbZ+sV6lVi1E9wPcKDvH1dd9N9mAOK9E1/KK
Nma8+o5Q10k1OSDaPR50aHY6iukFOJiGaM0L3FVsmJO6i0UXZ1ZztkPHM3xEE6rm
BYvgBYCeHSmMNWrdh/U8Pnte2dKn5GImOLzyK/CeZJpiE/HXsDGY68BedAQSClZn
TMQNpM6Rynmbn7tRrCf6aUDhFnmrcHea3WldI5dJzPe2UD0k3EBdO/S/yA6b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j68pKtkw19
2D2qmPlb2qdGCUYZUDLSbliveI2q0byQcMvoonHbZaQ3UfLzRzaSNQxOUgU+BXGJ
v40vQ1XaeKlVtXuzhsmJ4gZw
-----END PRIVATE KEY-----
claims:
- attr: acr
- attr: sub
hdr_name: jwt- Create the IBM Application Gateway configuration configmap.
kubectl create -f test_config.yaml- Paste the following into a file named deployment.yaml.
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
labels:
app: test
name: test
annotations:
ibm-application-gateway.security.ibm.com/env.LANG: en
ibm-application-gateway.security.ibm.com/configuration.test.type: configmap
ibm-application-gateway.security.ibm.com/configuration.test.name: test-config
ibm-application-gateway.security.ibm.com/configuration.test.dataKey: config
ibm-application-gateway.security.ibm.com/configuration.test.order: "1"
ibm-application-gateway.security.ibm.com/deployment.image: icr.io/ibmappgateway/ibm-application-gateway:22.07.0
ibm-application-gateway.security.ibm.com/deployment.imagePullPolicy: IfNotPresent
ibm-application-gateway.security.ibm.com/service.port: "30441"
spec:
selector:
matchLabels:
app: test
name: test
replicas: 1
template:
metadata:
labels:
app: test
name: test
spec:
containers:
- name: test
image: icr.io/ibmappgateway/ibm-application-gateway-demo-resource-server:22.07.0
imagePullPolicy: IfNotPresent- Create the deployment.
kubectl create -f deployment.yaml- Check the deployment. There should be a deployment application named “test” and a pod with a prefix of “test” that has 2 running containers.
kubectl get all
NAME READY STATUS RESTARTS AGE
pod/test-7797447ccf-zg7nq 2/2 Running 0 34s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 32m
service/test-ibm-application-gateway-sidecar-svc2tmd4 NodePort 10.111.179.97 <none> 8443:30441/TCP 34s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/test 1/1 1 1 34s
NAME DESIRED CURRENT READY AGE
replicaset.apps/test-7797447ccf 1 1 1 34s- Expose the IBM Application Gateway port.
kubectl port-forward deployment.apps/test 30112:8443- Leave the console as is and using a browser access the demo URL. Make sure its https rather than http. For example:
https://127.0.0.1:30112/demo-local
- The demo page is shown.
This page includes the following information which has been added by the IBM Application Gateway:
- JWT HTTP header
- AZN-CRED-REGISTRY-ID HTTP header
-
Exit the port-forwarding service by pressing ctrl-c in the shell.
-
Delete the test application.
kubectl delete -f deployment.yaml-
Check the deployment and service are removed.
-
Cleanup.
kubectl delete -f test_config.yaml
