With SSL

Setting up an ingress for Traefik for the OIG domain on Kubernetes

The instructions below explain how to set up Traefik as an ingress for the OIG domain with SSL termination.

Note: All the steps below should be performed on the administrative host.

  1. Install the Traefik repository

  2. Create a namespace

  3. Generate a SSL certificate

  4. Create a Kubernetes secret for SSL

  5. Install the Traefik

  6. Preparing the ingress values.yaml

  7. Creating the ingress

  8. Verify that you can access the domain URL

Install the Traefik repository

  1. Add the Helm chart repository for installing Traefik using the following command:

    $ helm repo add traefik https://helm.traefik.io/traefik --force-update
    

    The output will look similar to the following:

    "traefik" has been added to your repositories
    
  2. Update the repository using the following command:

    $ helm repo update
    

    The output will look similar to the following:

    Hang tight while we grab the latest from your chart repositories...
    ...Successfully got an update from the "traefik" chart repository
    Update Complete. Happy Helming!
    

Create a namespace

  1. Create a Kubernetes namespace for Traefik:

    $ kubectl create namespace traefik
    

    The output will look similar to the following:

    namespace/traefik created
    

Generate a SSL certificate

For production environments it is recommended to use a commercially available certificate, traceable to a trusted Certificate Authority. For sandbox environments, you can generate your own self-signed certificates.

Using a Third Party CA for Generating Certificates

Generate a private key and certificate signing request (CSR) using a tool of your choice. Send the CSR to your certificate authority (CA) to generate the certificate.

If you are configuring the ingress controller to use SSL, you must use a wildcard certificate to prevent issues with the Common Name (CN) in the certificate. A wildcard certificate is a certificate that protects the primary domain and it’s sub-domains. It uses a wildcard character (*) in the CN, for example *.yourdomain.com.

How you generate the key and certificate signing request for a wildcard certificate will depend on your Certificate Authority. Contact your Certificate Authority vendor for details.

In order to configure the ingress controller for SSL you require the following files:

  • The private key for your certificate, for example oig.key.
  • The certificate, for example oig.crt in PEM format.
  • The trusted certificate authority (CA) certificate, for example rootca.crt in PEM format.
  • If there are multiple trusted CA certificates in the chain, you need all the certificates in the chain, for example rootca1.crt, rootca2.crt etc.

Once you have received the files, perform the following steps:

  1. On the administrative host, create a $WORKDIR>/ssl directory and navigate to the folder:

     $ mkdir $WORKDIR>/ssl
     $ cd $WORKDIR>/ssl
    
  2. Copy the files listed above to the $WORKDIR>/ssl directory.

  3. If your CA has multiple certificates in a chain, create a bundle.pem that contains all the CA certificates:

    $ cat rootca.pem rootca1.pem rootca2.pem >>bundle.pem
    

Using Self-Signed Certificates

  1. On the administrative host, create a $WORKDIR>/ssl directory and navigate to the folder:

     $ mkdir $WORKDIR>/ssl
     $ cd $WORKDIR>/ssl
    
  2. Run the following command to create the self-signed certificate:

    $ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout oig.key -out oig.crt -subj "/CN=<hostname>"
    

    For example:

    $ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout oig.key -out oig.crt -subj "/CN=oig.example.com"
    

    The output will look similar to the following:

    Generating a 2048 bit RSA private key
    ..........................................+++
    .......................................................................................................+++
    writing new private key to 'oig.key'
    -----
    

    ``

Create a Kubernetes secret for SSL

  1. Create a secret for SSL containing the SSL certificate by running the following command:

    $ kubectl -n traefik create secret tls <domain_uid>-tls-cert --key $WORKDIR/ssl/oig.key --cert $WORKDIR/ssl/oig.crt
    

    For example:

    $ kubectl -n traefik create secret tls governancedomain-tls-cert --key /scratch/OIGK8S/ssl/oig.key --cert /scratch/OIGK8S/ssl/oig.crt
    

    The output will look similar to the following:

    secret/governancedomain-tls-cert created
    
  2. Confirm that the secret is created by running the following command:

    $ kubectl get secret <domain_uid>-tls-cert -o yaml -n oigns
    

    For example:

    $ kubectl get secret governancedomain-tls-cert -o yaml -n oigns
    

    The output will look similar to the following:

    apiVersion: v1
    data:
      tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURGVENDQWYyZ0F3SUJBZ0lKQUl3ZjVRMWVxZnljTUEwR0NTcUdTSWIzRFFFQkN3VUFNQ0V4SHpBZEJnTlYKQkFNTUZtUmxiakF4WlhadkxuVnpMbTl5WVdOc1pTNWpiMjB3SGhjTk1qQXdPREV3TVRReE9UUXpXaGNOTWpFdwpPREV3TVRReE9UUXpXakFoTVI4d0hRWURWUVFEREJaa1pXNHdNV1YyYnk1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Bd0VqNUQrbkN1WTRrZVFLQmdFSkRHb0puM1NCRXcra2xXTE85N09aOApnc3lYQm9mUW1lRktIS2NHNzFZUFhJbTRlV1kyUi9KOCt5anc5b1FJQ3o5NlRidkdSZEN5QlJhbWhoTmFGUzVyCk9MZUc0ejVENE4zdThUc0dNem9QcU13KzBGSXJiQ3FzTnpGWTg3ekZweEdVaXZvRWZLNE82YkdERTZjNHFqNGEKNmlmK0RSRSt1TWRMWTQyYTA3ekoKLS0tLS1FTkQgUFJJVkFURSBLRVktLS0tLQo=
    kind: Secret
    metadata:
      creationTimestamp: "<DATE>"
      name: governancedomain-tls-cert
      namespace: oigns
      resourceVersion: "3319899"
      uid: 274cc960-281a-494c-a3e3-d93c3abd051f
    type: kubernetes.io/tls
    
    

Install the Traefik

If you can connect directly to a worler node IP address from a browser, then install Traefik with the --set service.spec.type=NodePort parameter.

If you are using a Managed Service for your Kubernetes cluster, for example Oracle Kubernetes Engine (OKE) on Oracle Cloud Infrastructure (OCI), and connect from a browser to the Load Balancer IP address, then use the --set service.spec.type=LoadBalancer parameter. This instructs the Managed Service to setup a Load Balancer to direct traffic to the Traefik ingress.

  1. Create a $WORKDIR/kubernetes/kubernetes/charts/traefik/traefik-ingress-values-override.yaml that contains the following: The configuration below deploys an ingress using LoadBalancer. If you prefer to use NodePort, change the configuration accordingly. For more details about Traefik configuration see: Traefik Ingress Controller.

    ingressRoute:
      dashboard:
        enabled: true
    providers:
      kubernetesCRD:
        enabled: true
      kubernetesIngress:
        enabled: true
    ports:
      traefik:
        port: 9000
        exposedPort: 9000
        protocol: TCP
      web:
        port: 8000
        exposedPort: 30305
        nodePort: 30305
        protocol: TCP
      websecure:
        port: 8443
        exposedPort: 30443
        nodePort: 30443
        protocol: TCP
    service:
      spec:
        type: LoadBalancer
    
  2. To install and configure Traefik ingress, run the following command:

    $ helm install traefik --namespace <namespace> \
    --values traefik-ingress-values-override.yaml \
    traefik/traefik
    
     where:
    
     + `<namespace>` is your namespace, for example `traefik`.
     + `ports.web.exposedPort` is the HTTP port that you want the controller to listen on, for example `30305`.
     + `ports.websecure.exposedPort` is the HTTPS port that you want the controller to listen on, for example `30443`.
     + `service.spec.type` is the controller type. If using NodePort set to `NodePort`.
    

Preparing the ingress values.yaml

  1. Setup routing rules by running the following commands:

    $ cd $WORKDIR/kubernetes/charts/ingress-per-domain
    

    Edit values.yaml and change the domainUID parameter to match your domainUID, for example domainUID: governancedomain. Change sslType to SSL. The file should look as follows:

    # Load balancer type. Supported values are: NGINX, TRAEFIK
    type: TRAEFIK
    
    # SSL configuration Type. Supported Values are : NONSSL,SSL
    sslType: SSL
    
    # domainType. Supported values are: oim
    domainType: oim
    
    #WLS domain as backend to the load balancer
    wlsDomain:
      domainUID: governancedomain
      adminServerName: AdminServer
      adminServerPort: 7001
      adminServerSSLPort:
      soaClusterName: soa_cluster
      soaManagedServerPort: 8001
      soaManagedServerSSLPort:
      oimClusterName: oim_cluster
      oimManagedServerPort: 14000
      oimManagedServerSSLPort:
    
    # Host  specific values
    hostName:
      enabled: false
      admin:
      runtime:
      internal:
    
    

Creating the ingress

  1. Create an Ingress for the domain (governancedomain-traefik), in the domain namespace by using the sample Helm chart:

    $ cd $WORKDIR
    $ helm install governancedomain-traefik kubernetes/charts/ingress-per-domain --namespace <domain_namespace> --values kubernetes/charts/ingress-per-domain/values.yaml
    

    For example:

    $ cd $WORKDIR
    $ helm install governancedomain-traefik kubernetes/charts/ingress-per-domain --namespace oigns --values kubernetes/charts/ingress-per-domain/values.yaml
    

    The output will look similar to the following:

    NAME: governancedomain-traefik
    LAST DEPLOYED:  <DATE>
    NAMESPACE: oigns
    STATUS: deployed
    REVISION: 1
    TEST SUITE: None
    
  2. Run the following command to show the ingress is created successfully:

    $ kubectl get ingressRoute -n <domain_namespace>
    

    For example:

    $ kubectl get ingressRoute -n oigns
    

    The output will look similar to the following:

    NAME          AGE
    oim-traefik   45s
    
  3. Find the NodePort of Traefik using the following command (only if you installed Traefik using NodePort):

    $ kubectl get services -n traefik -o jsonpath={.spec.ports[0].nodePort}” traefik-traefik
    
  4. To confirm that the new ingress is successfully routing to the domain’s server pods, run the following command to send a request to the URL for the WebLogic ReadyApp framework:

    Note: If using a load balancer for your ingress replace ${HOSTNAME}:${PORT} with ${LOADBALANCER-HOSTNAME}:${LOADBALANCER-PORT}.

    $ curl -v -k https://${HOSTNAME}:${PORT}/weblogic/ready
    

    For example:

    $ curl -v -k  https://oig.example.com:30443/weblogic/ready
    

    The output will look similar to the following:

    $ curl -v -k https://oig.example.com:30443/weblogic/ready
    * About to connect() to X.X.X.X port 30433 (#0)
    *   Trying X.X.X.X...
    * Connected to oig.example.com (X.X.X.X) port 30433 (#0)
    * Initializing NSS with certpath: sql:/etc/pki/nssdb
    * skipping SSL peer certificate verification
    * SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
    * Server certificate:
    *       subject: CN=oig.example.com
    *       start date: <DATE>
    *       expire date: <DATE>
    *       common name: oig.example.com
    *       issuer: CN=oig.example.com
    > GET /weblogic/ready HTTP/1.1
    > User-Agent: curl/7.29.0
    > Host: X.X.X.X:30433
    > Accept: */*
    >
    < HTTP/1.1 200 OK
    < Content-Length: 0
    < Connection: keep-alive
    <
    * Connection #0 to host X.X.X.X left intact
    

Verify that you can access the domain URL

After setting up the Traefik ingress, verify that the domain applications are accessible through the Traefik ingress port (for example 30433) as per Validate Domain URLs