Skip to content

Latest commit

 

History

History
167 lines (149 loc) · 5.55 KB

File metadata and controls

167 lines (149 loc) · 5.55 KB

Config-Apache-Http-with-ORDS-via-Sidecar-in-K8S

Requirement

We have requirement that we need to put http server in front of Oracle ORDS standalone(jetty) service. So we can get benefits from http server ie rewrite ,static web assets hosting...etc. The http server has very tight connections with ORDS or Tomcat ...etc. Often it uses localhost to proxypass the connections. K8S Pod address the tight combination of multiple containers in 1 pod. In this case we put apache http server as sidecar beside ORDS container in 1 pod, so these 2 work together seamlessly to provide service. Refer K8S doc

Create ORDS Container image

# LICENSE UPL 1.0
#
# Copyright (c) 1982-2017 Oracle and/or its affiliates. All rights reserved.
#
# ORACLE DOCKERFILES PROJECT
# --------------------------
# This is the Dockerfile for Oracle Rest Data Services
#
# REQUIRED FILES TO BUILD THIS IMAGE
# ----------------------------------
# (1) ords.3.0.10.165.06.53.zip
#     Download Oracle Rest Data Services from
#     http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/index.html
#
# HOW TO BUILD THIS IMAGE
# -----------------------
# Put the downloaded file in the same directory as this Dockerfile
# Run:
#      $ docker build -t oracle/restdataservices:3.0.10 .
#
# Pull base image
# ---------------
FROM store/oracle/serverjre:8

# Labels
# ----------
LABEL maintainer "gerald.venzl@oracle.com"

# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
ENV ORDS_HOME=/opt/oracle/ords \
    INSTALL_FILE=ords*.zip \
    CONFIG_PROPS="ords_params.properties.tmpl" \
    STANDALONE_PROPS="standalone.properties.tmpl" \
    RUN_FILE="runOrds.sh"

# Copy binaries
# -------------
COPY $INSTALL_FILE  $CONFIG_PROPS $STANDALONE_PROPS $RUN_FILE $ORDS_HOME/
COPY ./conf/  $ORDS_HOME/config/ords/conf/
COPY ./defaults.xml $ORDS_HOME/config/ords/
COPY ./standalone/ $ORDS_HOME/config/ords/standalone/


# Setup filesystem and oracle user
# Adjust file permissions, go to /opt/oracle as user 'oracle' to proceed with ORDS installation
# ------------------------------------------------------------
RUN mkdir -p  $ORDS_HOME/doc_root && \
    chmod ug+x $ORDS_HOME/*.sh && \
    groupadd -g 54322 dba && \
    useradd -u 54321 -d /home/oracle -g dba -m -s /bin/bash oracle && \
    cd $ORDS_HOME && \
    jar -xf $INSTALL_FILE && \
    rm $INSTALL_FILE && \
    mkdir -p $ORDS_HOME/config/ords && \
    java -jar $ORDS_HOME/ords.war configdir $ORDS_HOME/config && \
    ln -s $ORDS_HOME/config/ords $ORDS_HOME/config/apex && \
    chown -R oracle:dba $ORDS_HOME

# Finalize setup
# -------------------
USER oracle
WORKDIR /home/oracle

VOLUME ["$ORDS_HOME/config/ords"]
EXPOSE 8888

# Define default command to start Oracle Database.
CMD $ORDS_HOME/$RUN_FILE

Create Apache Http Container image

  • AJP is not supported on ORDS, we use mod_proxy(proxypass and ProxyPassReverse )to handle java apps traffic. Refer note
  • Base image please refer docker hub
  • Sample Dockerfile partial httpd.conf file are like
FROM httpd:2.4
COPY ./images/ /usr/local/apache2/htdocs/images/
COPY httpd.conf /usr/local/apache2/conf/
Listen 80
<VirtualHost *:80>
    DocumentRoot /usr/local/apache2/htdocs/
    Alias /i/ "/usr/local/apache2/htdocs/images/"
    Alias /livesql/ "/usr/local/apache2/htdocs/images/livesql/"
    Alias /18c "/usr/local/apache2/htdocs/images/18c/"

    AddType text/xml xbl
    AddType text/x-component htc

    <Directory /usr/local/apache2/htdocs/>
        AllowOverride none
        Order deny,allow
        Allow from all
    </Directory>

    #<Directory /i/>
    <Directory /usr/local/apache2/htdocs/images/>
        Header set X-Frame-Options "deny"
    </Directory>

    #<Directory /livesql/>
    <Directory /usr/local/apache2/htdocs/images/livesql/>
        Header set X-Frame-Options "deny"
    </Directory>

     RewriteEngine On
     RewriteRule ^/$ /apex/f?p=590:1000 [R]
     RewriteRule ^/index.html /apex/f?p=590:1000 [R]
     RewriteRule ^/apex$ /apex/f?p=590:1000 [R]
     RewriteRule ^/apex/$ /apex/f?p=590:1000 [R]

     ProxyPass "/apex" "http://localhost:8888/apex" retry=60
     ProxyPassReverse /apex http://localhost:8888/apex
     ProxyPreserveHost On
</VirtualHost>

Yaml file to put Http as sidecar in the pod

  • apexohs:v2 is the sidecar , listens on port 7777 and proxy traffic to ORDS apexords:v18 which listens on localhost:8888
apiVersion: apps/v1
kind: Deployment
metadata:
  name: livesqlstg-mt-ohs-deployment
  labels:
    name: livesqlstg-service
spec:
  replicas: 1
  selector:
      matchLabels:
         name: livesqlstg-service
  template:
       metadata:
          labels:
             name: livesqlstg-service
       spec:
         containers:
           - name: ords
             image: apexords:v18
             imagePullPolicy: IfNotPresent
             ports:
                - containerPort: 8888
           - name: ohs
             image: apexohs:v2
             imagePullPolicy: IfNotPresent
             ports:
                - containerPort: 7777
         imagePullSecrets:
            - name: iad-ocir-secret
         nodeSelector:
             mthost: livesqlsb