|
| 1 | +# Deploying Oracle HTTP Server in Kubernetes |
| 2 | + |
| 3 | +For full documentation see: [https://oracle.github.io/fmw-kubernetes/ohs](https://oracle.github.io/fmw-kubernetes/ohs) |
| 4 | + |
| 5 | + |
| 6 | +## Obtaining the Scripts |
| 7 | + |
| 8 | +The sample scripts are available for download from GitHub. |
| 9 | + |
| 10 | +To obtain the scripts, use the following command: |
| 11 | + |
| 12 | +``` |
| 13 | +git clone https://github.com/oracle/fmw-kubernetes.git |
| 14 | +``` |
| 15 | + |
| 16 | +The scripts appear in the following directory: |
| 17 | + |
| 18 | +``` |
| 19 | +fmw-kubernetes/OracleHTTPServer/kubernetes |
| 20 | +``` |
| 21 | + |
| 22 | + |
| 23 | +## Scope |
| 24 | +This section lists the actions that the scripts perform as part of the deployment process. It also lists the tasks the scripts do not perform. |
| 25 | + |
| 26 | +### What the Scripts Will do |
| 27 | + |
| 28 | +The scripts will deploy Oracle HTTP Server in Kubernetes. |
| 29 | + |
| 30 | +The scripts perform the following actions: |
| 31 | + |
| 32 | +* Create an Oracle HTTP Server Instance in Kubernetes, with your own configuration. |
| 33 | +* Deploy Oracle WebGate and its associated configuration. |
| 34 | +* Create a NodePort Service for accessing the Oracle HTTP Server |
| 35 | + |
| 36 | +## Create a Namespace |
| 37 | + |
| 38 | +Create a namespace for your Oracle HTTP Server: |
| 39 | + |
| 40 | +`kubectl create namespace ohsns` |
| 41 | + |
| 42 | +## Create Secrets |
| 43 | + |
| 44 | +### Create Registry Secret |
| 45 | + |
| 46 | +If you are pulling your container image from a protected registry then you must create a secret with the connection credentials, for example, |
| 47 | + |
| 48 | +`kubectl create secret -n hosts docker-registry regcred --docker-server=<REGISTRY> --docker-username=<REG_USER> --docker-password=<REG_PWD>` |
| 49 | + |
| 50 | +Where: |
| 51 | + |
| 52 | +* \<REGISTRY\> is the name of the registry you are using. |
| 53 | +* \<REG_USER\> is the name of the user you use to connect to the registry. |
| 54 | +* \<REG_PWD\> is the password you use to connect to the registry. |
| 55 | + |
| 56 | + |
| 57 | +### Create OHS Secret |
| 58 | + |
| 59 | +The Oracle HTTP Server requires a username and password for the standalone OHS domain. To create this secret use the following command: |
| 60 | + |
| 61 | +`kubectl create secret generic ohs-secret -n\<namespace> --from-literal=username=weblogic --from-literal=password='<password>'` |
| 62 | + |
| 63 | +Replace \<password\> with a password of your choice. |
| 64 | + |
| 65 | +## Prepare your OHS configuration files |
| 66 | + |
| 67 | +Before you deploy OHS, you must prepare your OHS configuration files. Oracle HTTP Server in containers stores the OHS configuration inside Kubernetes configmaps, rather than on the filesystem. This allows the configuration to be independent of both the instance and filesystem. |
| 68 | + |
| 69 | +The steps below assume familiarity with on premises Oracle HTTP Server in terms of general configuration and use of Oracle WebGate. |
| 70 | + |
| 71 | +**Note:** Administrators should be aware of the following: |
| 72 | + |
| 73 | +* If you do not specify configuration files beforehand, then the OHS container is deployed with a default configuration of Oracle HTTP Server. |
| 74 | +* The directories listed below are optional. For example, if you do not want to deploy WebGate then you do not need to create the webgateConf and webgateWallet directories. Similarly, if you do not want to copy files to htdocs then you do not need to create the htdocs directory. |
| 75 | + |
| 76 | +Create the following directories for your OHS configuration: |
| 77 | + |
| 78 | +``` |
| 79 | +mkdir -p $WORKDIR/ohsConfig/httpconf |
| 80 | +mkdir -p $WORKDIR/ohsConfig/moduleconf |
| 81 | +mkdir -p $WORKDIR/ohsConfig/htdocs |
| 82 | +mkdir -p $WORKDIR/ohsConfig/htdocs/myapp |
| 83 | +mkdir -p $WORKDIR/ohsConfig/webgate/config/wallet |
| 84 | +mkdir -p $WORKDIR/ohsConfig/wallet/mywallet |
| 85 | +``` |
| 86 | + |
| 87 | +**Where:** |
| 88 | + |
| 89 | +* **httpconf** - contains any configuration files you want to configure that are usually found in the $OHS\_DOMAIN\_HOME/config/fmwconfig/components/OHS/ohs1 directory. For example httpd.conf, ssl.conf and mod\_wl\_ohs.conf. The webgate.conf does not need to be copied as this will get generated automatically if deploying with WebGate. |
| 90 | +* **moduleconf** - contains any additional config files, for example virtual host configuration files that you want to copy to the $OHS\_DOMAIN\_HOME/config/fmwconfig/components/OHS/ohs1/moduleconf folder in the container. |
| 91 | +* **htdocs** - contains any html files, or similar, that you want to copy to the $OHS\_DOMAIN\_HOME/config/fmwconfig/components/OHS/ohs1/htdocs folder in the container. |
| 92 | +* **htdocs/myapp** - myapp is an example directory name that exists under htdocs. If you need to copy any directories under htdocs above, then create the directories you require. |
| 93 | +* **webgate/config** - contains the extracted WebGate configuration. For example, when you download the \<agent\>.zip file from Oracle Access Management Console, you extract the zip file into this directory. If you are accessing OAM URL’s via SSL, this directory must also contain the Certificate Authority cacert.pem file that signed the certificate of the OAM entry point. For example, if you will access OAM via a HTTPS Load Balancer URL, then cacert.pem is the CA certificate that signed the load balancer certificate. |
| 94 | +* **webgate/config/wallet** - contains the contents of the wallet directory extracted from the \<agent.zip\> file. |
| 95 | +* **wallet/mywallet** - If OHS is to be configured to use SSL, this directory contains the preconfigured OHS Wallet file cwallet.sso. |
| 96 | + |
| 97 | +**Note:** Administrators should be aware of the following if configuring OHS for SSL: |
| 98 | + |
| 99 | +* The wallet must contain a valid certificate. |
| 100 | +* Only auto-login-only wallets (cwallet.sso only) are supported. For example, wallets created with orapki using the -auto-login-only option. Password protected wallets (ewallet.p12) are not supported. |
| 101 | +* You must configure ssl.conf in $WORKDIR/ohsConfig/httpconf and set the directory for SSLWallet to: SSLWallet "${ORACLE\_INSTANCE}/config/fmwconfig/components/${COMPONENT\_TYPE}/instances/${COMPONENT\_NAME}/keystores/wallet/mywallet". |
| 102 | + |
| 103 | +An example file system may contain the following: |
| 104 | + |
| 105 | +``` |
| 106 | +ls -R $WORKDIR/ohsConfig |
| 107 | +
|
| 108 | +/home/opc/OHSK8S/ohsConfig: |
| 109 | +
|
| 110 | +htdocs httpconf moduleconf wallet webgate |
| 111 | +
|
| 112 | +/home/opc/OHSK8S/ohsConfig/htdocs: |
| 113 | +
|
| 114 | +myapp mypage.html |
| 115 | +
|
| 116 | +/home/opc/OHSK8S/ohsConfig/htdocs/myapp: |
| 117 | +
|
| 118 | +index.html |
| 119 | +
|
| 120 | +/home/opc/OHSK8S/ohsConfig/httpconf: |
| 121 | +
|
| 122 | +httpd.conf mod_wl_ohs.conf ssl.conf |
| 123 | +
|
| 124 | +/home/opc/OHSK8S/ohsConfig/moduleconf: |
| 125 | +
|
| 126 | +vh.conf |
| 127 | +
|
| 128 | +/home/opc/OHSK8S/ohsConfig/wallet: |
| 129 | +
|
| 130 | +mywallet |
| 131 | +
|
| 132 | +/home/opc/OHSK8S/ohsConfig/wallet/mywallet: |
| 133 | +
|
| 134 | +cwallet.sso |
| 135 | +
|
| 136 | +/home/opc/OHSK8S/ohsConfig/webgate: |
| 137 | +
|
| 138 | +config |
| 139 | +
|
| 140 | +/home/opc/OHSK8S/ohsConfig/webgate/config: |
| 141 | +
|
| 142 | +cacert.pem cwallet.sso cwallet.sso.lck ObAccessClient.xml wallet |
| 143 | +
|
| 144 | +/home/opc/OHSK8S/ohsConfig/webgate/config/wallet: |
| 145 | +
|
| 146 | +cwallet.sso cwallet.sso.lck |
| 147 | +``` |
| 148 | + |
| 149 | +## Create configmaps for the OHS configuration files |
| 150 | + |
| 151 | +**Note:** Before following this section, make sure you have created the directories and files as per Prepare your OHS configuration files. |
| 152 | + |
| 153 | +Run the following commands to create the required configmaps for the OHS directories and files created in Prepare your OHS configuration files. |
| 154 | + |
| 155 | +``` |
| 156 | +cd $WORKDIR |
| 157 | + |
| 158 | +kubectl create cm -n ohsns ohs-config --from-file=ohsConfig/moduleconf |
| 159 | +kubectl create cm -n ohsns ohs-httpd --from-file=ohsConfig/httpconf |
| 160 | +kubectl create cm -n ohsns ohs-htdocs --from-file=ohsConfig/htdocs |
| 161 | +kubectl create cm -n ohsns ohs-myapp --from-file=ohsConfig/htdocs/myapp |
| 162 | +kubectl create cm -n ohsns webgate-config --from-file=ohsConfig/webgate/config |
| 163 | +kubectl create cm -n ohsns webgate-wallet --from-file=ohsConfig/webgate/config/wallet |
| 164 | +kubectl create cm -n ohsns ohs-wallet --from-file=ohsConfig/wallet/mywallet |
| 165 | +``` |
| 166 | +**Note:** Only create the configmaps for directories that you want to copy to OHS. |
| 167 | + |
| 168 | + |
| 169 | + |
| 170 | +## Filling in the Sample Files |
| 171 | + |
| 172 | +### Prepare the ohs.yaml file |
| 173 | + |
| 174 | +In this section you prepare the `ohs.yaml` file ready for OHS deployment. |
| 175 | + |
| 176 | +Make a copy of the ohs.yaml file: |
| 177 | + |
| 178 | + `$ cp ohs.yaml ohs.yaml.orig` |
| 179 | + |
| 180 | +Edit the ohs.yaml and change the following parameters to match your installation: |
| 181 | + |
| 182 | +**Notes:** |
| 183 | + |
| 184 | +* During the earlier creation of the namespace, configmaps, and secret, if you changed the names from the given examples, then you will need to update the values accordingly. |
| 185 | +* All configMaps are shown for completeness. Remove any configMaps that you are not using, for example if you don’t require htdocs then remove the ohs-htdocs configMap. If you are not deploying webgate then remove the webgate-config and webgate-wallet configMaps, and so forth. |
| 186 | +* If you have created any additional directories under htdocs, then add the additional entries in that match the configmap and directory names. |
| 187 | +* All configMaps used must mount to the directories stated. |
| 188 | +* Change the image to the correct image tag on Oracle Container Registry. If you are using your own container registry for the image, you will need to change the image location appropriately. If your own container registry is open, you do not need the imagePullSecrets. |
| 189 | +* Ports can be changed if required. |
| 190 | +* Set DEPLOY_WG to true or false depending on whether webgate is to be deployed. |
| 191 | + |
| 192 | +### Prepare the ohs_service.yaml file |
| 193 | + |
| 194 | +Make a copy of the ohs_service.yaml file: |
| 195 | + |
| 196 | +``` |
| 197 | +cd $WORKDIR |
| 198 | +cp ohs_service.yaml ohs_service.yaml.orig |
| 199 | +``` |
| 200 | +Edit the ohs_service.yaml and modify the file accordingly. For example, if you are using your own httpd.conf file and have changed the port to anything other than 7777, you must change the targetPort and port to match. Similarly, if you don’t require SSL, then you would remove the section relating to -port: 4443. |
| 201 | + |
| 202 | +## Deploying Oracle HTTP Server |
| 203 | + |
| 204 | +### Creating the OHS Container |
| 205 | + |
| 206 | +In this section you create the OHS container using the ohs.yaml file created in Prepare the ohs.yaml file. |
| 207 | + |
| 208 | +Run the following command to create the OHS container: |
| 209 | + |
| 210 | +`kubectl create -f $WORKDIR/ohs.yaml` |
| 211 | + |
| 212 | +The output will look similar to the following: |
| 213 | + |
| 214 | +configmap/ohs-script-configmap created |
| 215 | + |
| 216 | +deployment.apps/ohs-domain created |
| 217 | + |
| 218 | +Run the following command to view the status of the pods: |
| 219 | + |
| 220 | +`kubectl get pods -n <namespace> -w` |
| 221 | + |
| 222 | +### Creating OHS NodePort Service |
| 223 | + |
| 224 | +Run the following command to create a Kubernetes service nodeport for OHS. |
| 225 | + |
| 226 | +**Note:** Administrators should be aware of the following: |
| 227 | + |
| 228 | +As this is a Kubernetes service it will deploy to whichever node it is run from. If that node goes down then it will start on another node. |
| 229 | + |
| 230 | +If you create another OHS container on a different port, you will need to create another nodeport service for that OHS. |
| 231 | + |
| 232 | +`kubectl create -f $WORKDIR/ohs_service.yaml` |
| 233 | + |
| 234 | +The output will look similar to the following: |
| 235 | + |
| 236 | +service/ohs-domain-nodeport created |
| 237 | + |
| 238 | +Validate the service has been created using the command: |
| 239 | + |
| 240 | +`kubectl get service -n <namespace>` |
| 241 | + |
| 242 | + |
0 commit comments