diff --git a/advanced/pattern-2/README.md b/advanced/pattern-2/README.md index 6560234a..7c9252db 100644 --- a/advanced/pattern-2/README.md +++ b/advanced/pattern-2/README.md @@ -88,18 +88,18 @@ kubectl config set-context $(kubectl config current-context) --namespace=wso2 The Kubernetes Deployment definition file(s) that need to be updated are as follows: -* `/advanced/pattern-2//apim-analytics/wso2apim-analytics-deployment.yaml` -* `/advanced/pattern-2//apim-gw/wso2apim-gateway-deployment.yaml` -* `/advanced/pattern-2//apim-pub-store-tm/wso2apim-pub-store-tm-1-deployment.yaml` -* `/advanced/pattern-2//apim-pub-store-tm/wso2apim-pub-store-tm-2-deployment.yaml` +* `/advanced/pattern-2/apim-analytics/wso2apim-analytics-deployment.yaml` +* `/advanced/pattern-2/apim-gw/wso2apim-gateway-deployment.yaml` +* `/advanced/pattern-2/apim-pub-store-tm/wso2apim-pub-store-tm-1-deployment.yaml` +* `/advanced/pattern-2/apim-pub-store-tm/wso2apim-pub-store-tm-2-deployment.yaml` If you are using WSO2 API Manager's Key Manager profile, edit the following file. -* `/advanced/pattern-2//apim-km/wso2apim-km-deployment.yaml` +* `/advanced/pattern-2/apim-km/wso2apim-km-deployment.yaml` Else, if you are using WSO2 Identity Server as Key Manager, edit the following file. -* `/advanced/pattern-2//apim-is-as-km/wso2apim-is-as-km-deployment.yaml` +* `/advanced/pattern-2/apim-is-as-km/wso2apim-is-as-km-deployment.yaml` ##### 4. Setup product database(s). @@ -109,24 +109,24 @@ on creating the required databases for the deployment. Provide appropriate connection URLs, corresponding to the created external databases and the relevant driver class names for the data sources defined in the following files: -* `/advanced/pattern-2//confs/apim-analytics/conf/worker/deployment.yaml` -* `/advanced/pattern-2//confs/apim-pub-store-tm-1/datasources/master-datasources.xml` -* `/advanced/pattern-2//confs/apim-pub-store-tm-2/datasources/master-datasources.xml` +* `/advanced/pattern-2/confs/apim-analytics/conf/worker/deployment.yaml` +* `/advanced/pattern-2/confs/apim-pub-store-tm-1/datasources/master-datasources.xml` +* `/advanced/pattern-2/confs/apim-pub-store-tm-2/datasources/master-datasources.xml` If you are using WSO2 API Manager's Key Manager profile, edit the following file. -* `/advanced/pattern-2//confs/apim-km/datasources/master-datasources.xml` +* `/advanced/pattern-2/confs/apim-km/datasources/master-datasources.xml` Else, if you are using WSO2 Identity Server as Key Manager, edit the following file. -* `/advanced/pattern-2//confs/apim-is-as-km/datasources/master-datasources.xml` +* `/advanced/pattern-2/confs/apim-is-as-km/datasources/master-datasources.xml` Please refer WSO2's [official documentation](https://docs.wso2.com/display/ADMIN44x/Configuring+master-datasources.xml) on configuring data sources. **Note**: * For **evaluation purposes**, you can use Kubernetes resources provided in the directory
-`/advanced/pattern-2//extras/rdbms/mysql` for deploying the product databases, using MySQL in Kubernetes. However, this approach of product database deployment is +`/advanced/pattern-2/extras/rdbms/mysql` for deploying the product databases, using MySQL in Kubernetes. However, this approach of product database deployment is **not recommended** for a production setup. * For using these Kubernetes resources, @@ -134,7 +134,7 @@ Please refer WSO2's [official documentation](https://docs.wso2.com/display/ADMIN first create a Kubernetes ConfigMap for passing database script(s) to the deployment. ``` - kubectl create configmap mysql-dbscripts --from-file=/advanced/pattern-2//extras/confs/mysql/dbscripts/ + kubectl create configmap mysql-dbscripts --from-file=/advanced/pattern-2/extras/confs/mysql/dbscripts/ ``` Here, a Network File System (NFS) is needed to be used for persisting MySQL DB data. @@ -144,20 +144,20 @@ Please refer WSO2's [official documentation](https://docs.wso2.com/display/ADMIN Provide read-write-execute permissions to other users for the created folder. Update the Kubernetes Persistent Volume resource with the corresponding NFS server IP (`NFS_SERVER_IP`) and exported, - NFS server directory path (`NFS_LOCATION_PATH`) in `/advanced/pattern-2//extras/rdbms/volumes/persistent-volumes.yaml`. + NFS server directory path (`NFS_LOCATION_PATH`) in `/advanced/pattern-2/extras/rdbms/volumes/persistent-volumes.yaml`. Deploy the persistent volume resource and volume claim as follows: ``` - kubectl create -f /advanced/pattern-2//extras/rdbms/mysql/mysql-persistent-volume-claim.yaml - kubectl create -f /advanced/pattern-2//extras/rdbms/volumes/persistent-volumes.yaml + kubectl create -f /advanced/pattern-2/extras/rdbms/mysql/mysql-persistent-volume-claim.yaml + kubectl create -f /advanced/pattern-2/extras/rdbms/volumes/persistent-volumes.yaml ``` Then, create a Kubernetes service (accessible only within the Kubernetes cluster), followed by the MySQL Kubernetes deployment, as follows: ``` - kubectl create -f /advanced/pattern-2//extras/rdbms/mysql/mysql-service.yaml - kubectl create -f /advanced/pattern-2//extras/rdbms/mysql/mysql-deployment.yaml + kubectl create -f /advanced/pattern-2/extras/rdbms/mysql/mysql-service.yaml + kubectl create -f /advanced/pattern-2/extras/rdbms/mysql/mysql-deployment.yaml ``` ##### 5. Create a Kubernetes role and a role binding necessary for the Kubernetes API requests made from Kubernetes membership scheme. @@ -169,7 +169,7 @@ kubectl create -f /rbac/rbac.yaml ##### 6. Setup a Network File System (NFS) to be used for persistent storage. Create and export unique directories within the NFS server instance for each Kubernetes Persistent Volume resource defined in the -`/advanced/pattern-2//volumes/persistent-volumes.yaml` file. +`/advanced/pattern-2/volumes/persistent-volumes.yaml` file. Grant ownership to `wso2carbon` user and `wso2` group, for each of the previously created directories. @@ -211,79 +211,79 @@ Then, deploy the Kubernetes Persistent Volume and Volume Claim resources as foll `/repository/deployment/server` directory in Gateway profile deployment. ``` -kubectl create -f /advanced/pattern-2//apim-gw/wso2apim-gateway-volume-claim.yaml +kubectl create -f /advanced/pattern-2/apim-gw/wso2apim-gateway-volume-claim.yaml ``` * Kubernetes Persistent Volume Claim resource for the shared volume mount for runtime artifacts created at `/repository/deployment/server` directory in Publisher-Store-Traffic-Manager profile deployment. ``` -kubectl create -f /advanced/pattern-2//apim-pub-store-tm/wso2apim-pub-store-tm-volume-claim.yaml +kubectl create -f /advanced/pattern-2/apim-pub-store-tm/wso2apim-pub-store-tm-volume-claim.yaml ``` * [Optional] If you are using WSO2 Identity Server as the Key Manager, Kubernetes Persistent Volume Claim resource for the shared volume mount for runtime artifacts created at `/repository/deployment/server` directory in Key Manager profile deployment. ``` -kubectl create -f /advanced/pattern-2//apim-is-as-km/wso2apim-is-as-km-volume-claim.yaml +kubectl create -f /advanced/pattern-2/apim-is-as-km/wso2apim-is-as-km-volume-claim.yaml ``` * Kubernetes Persistent Volume resources for the above Volume Claims created. ``` -kubectl create -f /advanced/pattern-2//volumes/persistent-volumes.yaml +kubectl create -f /advanced/pattern-2/volumes/persistent-volumes.yaml ``` ##### 7. Create Kubernetes ConfigMaps for passing WSO2 product configurations into the Kubernetes cluster. ``` -kubectl create configmap apim-analytics-conf-worker --from-file=/advanced/pattern-2//confs/apim-analytics/conf/worker +kubectl create configmap apim-analytics-conf-worker --from-file=/advanced/pattern-2/confs/apim-analytics/conf/worker -kubectl create configmap apim-pub-store-tm-1-conf --from-file=/advanced/pattern-2//confs/apim-pub-store-tm-1/ -kubectl create configmap apim-pub-store-tm-1-conf-datasources --from-file=/advanced/pattern-2//confs/apim-pub-store-tm-1/datasources/ -kubectl create configmap apim-pub-store-tm-2-conf --from-file=/advanced/pattern-2//confs/apim-pub-store-tm-2/ -kubectl create configmap apim-pub-store-tm-2-conf-datasources --from-file=/advanced/pattern-2//confs/apim-pub-store-tm-2/datasources/ +kubectl create configmap apim-pub-store-tm-1-conf --from-file=/advanced/pattern-2/confs/apim-pub-store-tm-1/ +kubectl create configmap apim-pub-store-tm-1-conf-datasources --from-file=/advanced/pattern-2/confs/apim-pub-store-tm-1/datasources/ +kubectl create configmap apim-pub-store-tm-2-conf --from-file=/advanced/pattern-2/confs/apim-pub-store-tm-2/ +kubectl create configmap apim-pub-store-tm-2-conf-datasources --from-file=/advanced/pattern-2/confs/apim-pub-store-tm-2/datasources/ -kubectl create configmap apim-gateway-conf --from-file=/advanced/pattern-2//confs/apim-gateway/ -kubectl create configmap apim-gateway-conf-axis2 --from-file=/advanced/pattern-2//confs/apim-gateway/axis2/ +kubectl create configmap apim-gateway-conf --from-file=/advanced/pattern-2/confs/apim-gateway/ +kubectl create configmap apim-gateway-conf-axis2 --from-file=/advanced/pattern-2/confs/apim-gateway/axis2/ ``` If you are using WSO2 API Manager's Key Manager profile, deploy the following Kubernetes ConfigMaps. ``` -kubectl create configmap apim-km-conf --from-file=/advanced/pattern-2//confs/apim-km/ -kubectl create configmap apim-km-conf-axis2 --from-file=/advanced/pattern-2//confs/apim-km/axis2/ -kubectl create configmap apim-km-conf-datasources --from-file=/advanced/pattern-2//confs/apim-km/datasources/ +kubectl create configmap apim-km-conf --from-file=/advanced/pattern-2/confs/apim-km/ +kubectl create configmap apim-km-conf-axis2 --from-file=/advanced/pattern-2/confs/apim-km/axis2/ +kubectl create configmap apim-km-conf-datasources --from-file=/advanced/pattern-2/confs/apim-km/datasources/ ``` Else, if you are using WSO2 Identity Server as Key Manager, deploy the following Kubernetes ConfigMaps. ``` -kubectl create configmap apim-is-as-km-conf --from-file=/advanced/pattern-2//confs/apim-is-as-km/ -kubectl create configmap apim-is-as-km-conf-axis2 --from-file=/advanced/pattern-2//confs/apim-is-as-km/axis2/ -kubectl create configmap apim-is-as-km-conf-datasources --from-file=/advanced/pattern-2//confs/apim-is-as-km/datasources/ +kubectl create configmap apim-is-as-km-conf --from-file=/advanced/pattern-2/confs/apim-is-as-km/ +kubectl create configmap apim-is-as-km-conf-axis2 --from-file=/advanced/pattern-2/confs/apim-is-as-km/axis2/ +kubectl create configmap apim-is-as-km-conf-datasources --from-file=/advanced/pattern-2/confs/apim-is-as-km/datasources/ ``` ##### 8. Create Kubernetes Services for WSO2 API Manager and Analytics. ``` -kubectl create -f /advanced/pattern-2//apim-analytics/wso2apim-analytics-service.yaml -kubectl create -f /advanced/pattern-2//apim-pub-store-tm/wso2apim-pub-store-tm-1-service.yaml -kubectl create -f /advanced/pattern-2//apim-pub-store-tm/wso2apim-pub-store-tm-2-service.yaml -kubectl create -f /advanced/pattern-2//apim-pub-store-tm/wso2apim-pub-store-tm-service.yaml -kubectl create -f /advanced/pattern-2//apim-gw/wso2apim-gateway-service.yaml +kubectl create -f /advanced/pattern-2/apim-analytics/wso2apim-analytics-service.yaml +kubectl create -f /advanced/pattern-2/apim-pub-store-tm/wso2apim-pub-store-tm-1-service.yaml +kubectl create -f /advanced/pattern-2/apim-pub-store-tm/wso2apim-pub-store-tm-2-service.yaml +kubectl create -f /advanced/pattern-2/apim-pub-store-tm/wso2apim-pub-store-tm-service.yaml +kubectl create -f /advanced/pattern-2/apim-gw/wso2apim-gateway-service.yaml ``` If you are using WSO2 API Manager's Key Manager profile, deploy the following Kubernetes Service. ``` -kubectl create -f /advanced/pattern-2//apim-km/wso2apim-km-service.yaml +kubectl create -f /advanced/pattern-2/apim-km/wso2apim-km-service.yaml ``` Else, if you are using WSO2 Identity Server as Key Manager, deploy the following Kubernetes Service. ``` -kubectl create -f /advanced/pattern-2//apim-is-as-km/wso2apim-is-as-km-service.yaml +kubectl create -f /advanced/pattern-2/apim-is-as-km/wso2apim-is-as-km-service.yaml ``` ##### 9. Create Kubernetes Deployments for WSO2 API Manager and Analytics. @@ -291,7 +291,7 @@ kubectl create -f /advanced/pattern-2//apim-is-as-km/wso2apim-i * Create the Kubernetes Deployment for WSO2 API Manager Analytics Worker profile. ``` -kubectl create -f /advanced/pattern-2//apim-analytics/wso2apim-analytics-deployment.yaml +kubectl create -f /advanced/pattern-2/apim-analytics/wso2apim-analytics-deployment.yaml ``` Ensure that the Analytics Worker profile pod is successfully deployed and ready to serve requests. @@ -302,13 +302,13 @@ You can execute `kubectl get pods` command to achive this. If you are using WSO2 API Manager's Key Manager profile, create the following Kubernetes Deployment. ``` -kubectl create -f /advanced/pattern-2//apim-km/wso2apim-km-service.yaml +kubectl create -f /advanced/pattern-2/apim-km/wso2apim-km-deployment.yaml ``` Else, if you are using WSO2 Identity Server as Key Manager, create the following Kubernetes Deployment. ``` -kubectl create -f /advanced/pattern-2//apim-is-as-km/wso2apim-is-as-km-service.yaml +kubectl create -f /advanced/pattern-2/apim-is-as-km/wso2apim-is-as-km-deployment.yaml ``` Ensure that the Key Manager profile pod is successfully deployed and ready to serve requests. @@ -318,7 +318,7 @@ Ensure that the Key Manager profile pod is successfully deployed and ready to se Create the Kubernetes Deployment for the first node of WSO2 API Manager Publisher-Store-Traffic-Manager profiles. ``` -kubectl create -f /advanced/pattern-2//apim-pub-store-tm/wso2apim-pub-store-tm-1-deployment.yaml +kubectl create -f /advanced/pattern-2/apim-pub-store-tm/wso2apim-pub-store-tm-1-deployment.yaml ``` Ensure the Kubernetes pod for the first node of WSO2 API Manager Publisher-Store-Traffic-Manager profiles is successfully @@ -327,7 +327,7 @@ deployed and ready to serve requests. Then, create the Kubernetes Deployment for the second node of WSO2 API Manager Publisher-Store-Traffic-Manager profiles. ``` -kubectl create -f /advanced/pattern-2//apim-pub-store-tm/wso2apim-pub-store-tm-2-deployment.yaml +kubectl create -f /advanced/pattern-2/apim-pub-store-tm/wso2apim-pub-store-tm-2-deployment.yaml ``` Ensure the Kubernetes pod is up and running and ready to serve requests. @@ -335,7 +335,7 @@ Ensure the Kubernetes pod is up and running and ready to serve requests. * Create the Kubernetes Deployment for WSO2 API Manager Gateway profile. ``` -kubectl create -f /advanced/pattern-2//apim-gw/wso2apim-gateway-deployment.yaml +kubectl create -f /advanced/pattern-2/apim-gw/wso2apim-gateway-deployment.yaml ``` Ensure the Kubernetes pod for WSO2 API Manager's Gateway profile is up and running and ready to serve requests. @@ -350,8 +350,8 @@ please refer the official documentation, [NGINX Ingress Controller Installation Finally, deploy the WSO2 API Manager Kubernetes Ingress resources as follows: ``` -kubectl create -f /advanced/pattern-2//ingresses/wso2apim-gateway-ingress.yaml -kubectl create -f /advanced/pattern-2//ingresses/wso2apim-ingress.yaml +kubectl create -f /advanced/pattern-2/ingresses/wso2apim-gateway-ingress.yaml +kubectl create -f /advanced/pattern-2/ingresses/wso2apim-ingress.yaml ``` ##### 11. Access Management Consoles. @@ -392,7 +392,7 @@ simply run `kubectl scale` Kubernetes client command on the terminal. For example, the following command scales the WSO2 API Manager Gateway profile to the desired number of replicas. ``` -kubectl scale --replicas= -f /advanced/pattern-2//apim-gw/wso2apim-gateway-deployment.yaml +kubectl scale --replicas= -f /advanced/pattern-2/apim-gw/wso2apim-gateway-deployment.yaml ``` If `` is 2, you are here scaling up this deployment from 1 to 2 container replicas. diff --git a/advanced/pattern-3/README.md b/advanced/pattern-3/README.md new file mode 100644 index 00000000..f80a4a82 --- /dev/null +++ b/advanced/pattern-3/README.md @@ -0,0 +1,424 @@ +# Kubernetes Resources for a Fully Distributed deployment of WSO2 API Manager + +Core Kubernetes resources for [WSO2 API Manager deployment pattern 3](https://docs.wso2.com/display/AM260/Deployment+Patterns#DeploymentPatterns-Pattern3). +This consists of a fully distributed deployment of WSO2 API Manager with WSO2 API Manager Analytics support. + +![WSO2 API Manager pattern 3 deployment](pattern-3.png) + +## Contents + +* [Prerequisites](#prerequisites) +* [Quick Start Guide](#quick-start-guide) + +## Prerequisites + +* In order to use Docker images with WSO2 updates, you need an active WSO2 subscription. If you do not possess an active WSO2 + subscription, you can sign up for a WSO2 Free Trial Subscription from [here](https://wso2.com/free-trial-subscription). + Otherwise, you can proceed with Docker images which are created using GA releases.

+ +* Install [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [Kubernetes client](https://kubernetes.io/docs/tasks/tools/install-kubectl/) +in order to run the steps provided in the following quick start guide.

+ +* An already setup [Kubernetes cluster](https://kubernetes.io/docs/setup/pick-right-solution/).

+ +* A pre-configured Network File System (NFS) to be used as the persistent volume for artifact sharing and persistence. +In the NFS server instance, create a Linux system user account named `wso2carbon` with user id `802` and a system group named `wso2` with group id `802`. +Add the `wso2carbon` user to the group `wso2`. + +``` +groupadd --system -g 802 wso2 +useradd --system -g 802 -u 802 wso2carbon +``` + +## Quick Start Guide + +>In the context of this document, `KUBERNETES_HOME` will refer to a local copy of the [`wso2/kubernetes-apim`](https://github.com/wso2/kubernetes-apim/) +Git repository.
+ +##### 1. Clone the Kubernetes Resources for WSO2 API Manager Git repository. + +``` +git clone https://github.com/wso2/kubernetes-apim.git +``` + +##### 2. Create a namespace named `wso2` and a service account named `wso2svc-account`, within the namespace `wso2`. + +``` +kubectl create namespace wso2 +kubectl create serviceaccount wso2svc-account -n wso2 +``` + +Then, switch the context to new `wso2` namespace. + +``` +kubectl config set-context $(kubectl config current-context) --namespace=wso2 +``` + +##### 3. [Optional] If you are using Docker images with WSO2 updates, perform the following changes. + +* Change the Docker image names such that each Kubernetes Deployment use WSO2 product Docker images from [`WSO2 Docker Registry`](https://docker.wso2.com). + + Change the Docker image name, i.e. the `image` attribute under the [container specification](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.14/#container-v1-core) + of each Kubernetes Deployment resource. + + For example, change the default `wso2/wso2am:2.6.0` WSO2 API Manager Docker image available at [DockerHub](https://hub.docker.com/u/wso2/) to + `docker.wso2.com/wso2am:2.6.0` WSO2 API Manager Docker image available at [`WSO2 Docker Registry`](https://docker.wso2.com). + +* Create a Kubernetes Secret for pulling the required Docker images from [`WSO2 Docker Registry`](https://docker.wso2.com). + + Create a Kubernetes Secret named `wso2creds` in the cluster to authenticate with the WSO2 Docker Registry, to pull the required images. + + ``` + kubectl create secret docker-registry wso2creds --docker-server=docker.wso2.com --docker-username= --docker-password= --docker-email= + ``` + + `WSO2_USERNAME`: Your WSO2 username
+ `WSO2_PASSWORD`: Your WSO2 password + + Please see [Kubernetes official documentation](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-in-the-cluster-that-holds-your-authorization-token) + for further details. + + Also, add the created `wso2creds` Kubernetes Secret as an entry to Kubernetes Deployment resources. Please add the following entry + under the [Kubernetes Pod Specification](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.14/#podspec-v1-core) `PodSpec` in each Deployment resource. + + ``` + imagePullSecrets: + - name: wso2creds + ``` + +The Kubernetes Deployment definition file(s) that need to be updated are as follows: + +* `/advanced/pattern-3/apim-analytics/wso2apim-analytics-deployment.yaml` +* `/advanced/pattern-3/apim-gateway/wso2apim-gateway-deployment.yaml` +* `/advanced/pattern-3/apim-publisher/wso2apim-publisher-deployment.yaml` +* `/advanced/pattern-3/apim-store/wso2apim-store-deployment.yaml` +* `/advanced/pattern-3/apim-tm/wso2apim-tm-1-deployment.yaml` +* `/advanced/pattern-3/apim-tm/wso2apim-tm-2-deployment.yaml` + +If you are using WSO2 API Manager's Key Manager profile, edit the following file. + +* `/advanced/pattern-3/apim-km/wso2apim-km-deployment.yaml` + +Else, if you are using WSO2 Identity Server as Key Manager, edit the following file. + +* `/advanced/pattern-3/apim-is-as-km/wso2apim-is-as-km-deployment.yaml` + +##### 4. Setup product database(s). + +Setup the external product databases. Please refer to WSO2 API Manager's [official documentation](https://docs.wso2.com/display/AM260/Installing+and+Configuring+the+Databases) +on creating the required databases for the deployment. + +Provide appropriate connection URLs, corresponding to the created external databases and the relevant driver class names for the data sources defined in +the following files: + +* `/advanced/pattern-3/confs/apim-analytics/conf/worker/deployment.yaml` +* `/advanced/pattern-3/confs/apim-publisher/datasources/master-datasources.xml` +* `/advanced/pattern-3/confs/apim-store/datasources/master-datasources.xml` + +If you are using WSO2 API Manager's Key Manager profile, edit the following file. + +* `/advanced/pattern-3/confs/apim-km/datasources/master-datasources.xml` + +Else, if you are using WSO2 Identity Server as Key Manager, edit the following file. + +* `/advanced/pattern-3/confs/apim-is-as-km/datasources/master-datasources.xml` + +Please refer WSO2's [official documentation](https://docs.wso2.com/display/ADMIN44x/Configuring+master-datasources.xml) on configuring data sources. + +**Note**: + +* For **evaluation purposes**, you can use Kubernetes resources provided in the directory
+`/advanced/pattern-3/extras/rdbms/mysql` for deploying the product databases, using MySQL in Kubernetes. However, this approach of product database deployment is +**not recommended** for a production setup. + +* For using these Kubernetes resources, + + first create a Kubernetes ConfigMap for passing database script(s) to the deployment. + + ``` + kubectl create configmap mysql-dbscripts --from-file=/advanced/pattern-3/extras/confs/mysql/dbscripts/ + ``` + + Here, a Network File System (NFS) is needed to be used for persisting MySQL DB data. + + Create and export a directory within the NFS server instance. + + Provide read-write-execute permissions to other users for the created folder. + + Update the Kubernetes Persistent Volume resource with the corresponding NFS server IP (`NFS_SERVER_IP`) and exported, + NFS server directory path (`NFS_LOCATION_PATH`) in `/advanced/pattern-3/extras/rdbms/volumes/persistent-volumes.yaml`. + + Deploy the persistent volume resource and volume claim as follows: + + ``` + kubectl create -f /advanced/pattern-3/extras/rdbms/mysql/mysql-persistent-volume-claim.yaml + kubectl create -f /advanced/pattern-3/extras/rdbms/volumes/persistent-volumes.yaml + ``` + + Then, create a Kubernetes service (accessible only within the Kubernetes cluster), followed by the MySQL Kubernetes deployment, as follows: + + ``` + kubectl create -f /advanced/pattern-3/extras/rdbms/mysql/mysql-service.yaml + kubectl create -f /advanced/pattern-3/extras/rdbms/mysql/mysql-deployment.yaml + ``` + +##### 5. Create a Kubernetes role and a role binding necessary for the Kubernetes API requests made from Kubernetes membership scheme. + +``` +kubectl create -f /rbac/rbac.yaml +``` + +##### 6. Setup a Network File System (NFS) to be used for persistent storage. + +Create and export unique directories within the NFS server instance for each Kubernetes Persistent Volume resource defined in the +`/advanced/pattern-3/volumes/persistent-volumes.yaml` file. + +Grant ownership to `wso2carbon` user and `wso2` group, for each of the previously created directories. + +``` +sudo chown -R wso2carbon:wso2 +``` + +Grant read-write-execute permissions to the `wso2carbon` user, for each of the previously created directories. + +``` +chmod -R 700 +``` + +Update each Kubernetes Persistent Volume resource with the corresponding NFS server IP (`NFS_SERVER_IP`) and exported, NFS server directory path (`NFS_LOCATION_PATH`). + +**Note**: If you are **not** using WSO2 Identity Server as the Key Manager, comment out the corresponding Kubernetes Persistent Volume resource. + +``` +apiVersion: v1 +kind: PersistentVolume +metadata: + name: wso2apim-pattern-3-is-as-km-server-pv + labels: + purpose: wso2apim-pattern-3-km-shared +spec: + capacity: + storage: 1Gi + accessModes: + - ReadWriteMany + persistentVolumeReclaimPolicy: Retain + nfs: + server: + path: "" +``` + +Then, deploy the Kubernetes Persistent Volume and Volume Claim resources as follows: + +* Kubernetes Persistent Volume Claim resource for the shared volume mount for runtime artifacts created at +`/repository/deployment/server` directory in Gateway profile deployment. + +``` +kubectl create -f /advanced/pattern-3/apim-gateway/wso2apim-gateway-volume-claim.yaml +``` + +* Kubernetes Persistent Volume Claim resource for the shared volume mount for runtime artifacts created at +`/repository/deployment/server` directory in Traffic-Manager profile deployment. + +``` +kubectl create -f /advanced/pattern-3/apim-tm/wso2apim-tm-volume-claim.yaml +``` + +* [Optional] If you are using WSO2 Identity Server as the Key Manager, Kubernetes Persistent Volume Claim resource for the +shared volume mount for runtime artifacts created at `/repository/deployment/server` directory in Key Manager profile deployment. + +``` +kubectl create -f /advanced/pattern-3/apim-is-as-km/wso2apim-is-as-km-volume-claim.yaml +``` + +* Kubernetes Persistent Volume resources for the above Volume Claims created. + +``` +kubectl create -f /advanced/pattern-3/volumes/persistent-volumes.yaml +``` + +##### 7. Create Kubernetes ConfigMaps for passing WSO2 product configurations into the Kubernetes cluster. + +``` +kubectl create configmap apim-analytics-conf-worker --from-file=/advanced/pattern-3/confs/apim-analytics/conf/worker + +kubectl create configmap apim-pub-conf --from-file=/advanced/pattern-3/confs/apim-publisher/ +kubectl create configmap apim-pub-conf-datasources --from-file=/advanced/pattern-3/confs/apim-publisher/datasources + +kubectl create configmap apim-store-conf --from-file=/advanced/pattern-3/confs/apim-store/ +kubectl create configmap apim-store-conf-datasources --from-file=/advanced/pattern-3/confs/apim-store/datasources + +kubectl create configmap apim-tm-1-conf --from-file=/advanced/pattern-3/confs/apim-tm-1/ +kubectl create configmap apim-tm-1-conf-axis2 --from-file=/advanced/pattern-3/confs/apim-tm-1/axis2/ +kubectl create configmap apim-tm-1-conf-identity --from-file=/advanced/pattern-3/confs/apim-tm-1/identity/ +kubectl create configmap apim-tm-2-conf --from-file=/advanced/pattern-3/confs/apim-tm-2/ +kubectl create configmap apim-tm-2-conf-axis2 --from-file=/advanced/pattern-3/confs/apim-tm-2/axis2/ +kubectl create configmap apim-tm-2-conf-identity --from-file=/advanced/pattern-3/confs/apim-tm-2/identity/ + +kubectl create configmap apim-gateway-conf --from-file=/advanced/pattern-3/confs/apim-gateway/ +kubectl create configmap apim-gateway-conf-axis2 --from-file=/advanced/pattern-3/confs/apim-gateway/axis2/ +``` + +If you are using WSO2 API Manager's Key Manager profile, deploy the following Kubernetes ConfigMaps. + +``` +kubectl create configmap apim-km-conf --from-file=/advanced/pattern-3/confs/apim-km/ +kubectl create configmap apim-km-conf-datasources --from-file=/advanced/pattern-3/confs/apim-km/datasources/ +``` + +Else, if you are using WSO2 Identity Server as Key Manager, deploy the following Kubernetes ConfigMaps. + +``` +kubectl create configmap apim-is-as-km-conf --from-file=/advanced/pattern-3/confs/apim-is-as-km/ +kubectl create configmap apim-is-as-km-conf-datasources --from-file=/advanced/pattern-3/confs/apim-is-as-km/datasources/ +``` + +##### 8. Create Kubernetes Services for WSO2 API Manager and Analytics. + +``` +kubectl create -f /advanced/pattern-3/apim-analytics/wso2apim-analytics-service.yaml +kubectl create -f /advanced/pattern-3/apim-publisher/wso2apim-publisher-service.yaml +kubectl create -f /advanced/pattern-3/apim-store/wso2apim-store-service.yaml +kubectl create -f /advanced/pattern-3/apim-tm/wso2apim-tm-1-service.yaml +kubectl create -f /advanced/pattern-3/apim-tm/wso2apim-tm-2-service.yaml +kubectl create -f /advanced/pattern-3/apim-gateway/wso2apim-gateway-service.yaml +``` + +If you are using WSO2 API Manager's Key Manager profile, deploy the following Kubernetes Service. + +``` +kubectl create -f /advanced/pattern-3/apim-km/wso2apim-km-service.yaml +``` + +Else, if you are using WSO2 Identity Server as Key Manager, deploy the following Kubernetes Service. + +``` +kubectl create -f /advanced/pattern-3/apim-is-as-km/wso2apim-is-as-km-service.yaml +``` + +##### 9. Create Kubernetes Deployments for WSO2 API Manager and Analytics. + +* Create the Kubernetes Deployment for WSO2 API Manager Analytics Worker profile. + +``` +kubectl create -f /advanced/pattern-3/apim-analytics/wso2apim-analytics-deployment.yaml +``` + +Ensure that the Analytics Worker profile pod is successfully deployed and ready to serve requests. +You can execute `kubectl get pods` command to achieve this. + +* Create the Kubernetes Deployment for Key Manager profile. + +If you are using WSO2 API Manager's Key Manager profile, create the following Kubernetes Deployment. + +``` +kubectl create -f /advanced/pattern-3/apim-km/wso2apim-km-deployment.yaml +``` + +Else, if you are using WSO2 Identity Server as Key Manager, create the following Kubernetes Deployment. + +``` +kubectl create -f /advanced/pattern-3/apim-is-as-km/wso2apim-is-as-km-deployment.yaml +``` + +Ensure that the Key Manager profile pod is successfully deployed and ready to serve requests. + +* Create the Kubernetes Deployment for WSO2 API Manager Publisher profile. + +``` +kubectl create -f /advanced/pattern-3/apim-publisher/wso2apim-publisher-deployment.yaml +``` + +Ensure that the Publisher profile pod is successfully deployed and ready to serve requests. + +* Create the Kubernetes Deployment for WSO2 API Manager Store profile. + +``` +kubectl create -f /advanced/pattern-3/apim-store/wso2apim-store-deployment.yaml +``` + +Ensure that the Store profile pod is successfully deployed and ready to serve requests. + +* Create the Kubernetes Deployment for WSO2 API Manager Traffic-Manager profiles. + +Create the Kubernetes Deployment for the first node of WSO2 API Manager Traffic-Manager profiles. + +``` +kubectl create -f /advanced/pattern-3/apim-tm/wso2apim-tm-1-deployment.yaml +``` + +Ensure the Kubernetes pod for the first node of WSO2 API Manager Traffic-Manager profiles is successfully +deployed and ready to serve requests. + +Then, create the Kubernetes Deployment for the second node of WSO2 API Manager Traffic-Manager profiles. + +``` +kubectl create -f /advanced/pattern-3/apim-tm/wso2apim-tm-2-deployment.yaml +``` + +Ensure the Kubernetes pod is up and running and ready to serve requests. + +* Create the Kubernetes Deployment for WSO2 API Manager Gateway profile. + +``` +kubectl create -f /advanced/pattern-3/apim-gateway/wso2apim-gateway-deployment.yaml +``` + +Ensure the Kubernetes pod for WSO2 API Manager's Gateway profile is up and running and ready to serve requests. + +##### 10. Deploy Kubernetes Ingress resources. + +The WSO2 API Manager Kubernetes Ingress resources uses the NGINX Ingress Controller maintained by Kubernetes. + +In order to enable the NGINX Ingress controller in the desired cloud or on-premise environment, +please refer the official documentation, [NGINX Ingress Controller Installation Guide](https://kubernetes.github.io/ingress-nginx/deploy/). + +Finally, deploy the WSO2 API Manager Kubernetes Ingress resources as follows: + +``` +kubectl create -f /advanced/pattern-3/ingresses/wso2apim-gateway-ingress.yaml +kubectl create -f /advanced/pattern-3/ingresses/wso2apim-ingress.yaml +``` + +##### 11. Access Management Consoles. + +Default deployment will expose `wso2apim-publisher`, `wso2apim-publisher` and `wso2apim-gateway` hosts. + +To access the console in the environment, + +a. Obtain the external IP (`EXTERNAL-IP`) of the Ingress resources by listing down the Kubernetes Ingresses. + + ``` + kubectl get ing + ``` + +e.g. + +``` +NAME HOSTS ADDRESS PORTS AGE +wso2apim-ingress wso2apim-publisher,wso2apim-store 80, 443 7m +wso2apim-gateway-ingress wso2apim-gateway 80, 443 6m +``` + +b. Add the above host as an entry in `/etc/hosts` file as follows: + +``` + wso2apim-publisher + wso2apim-store + wso2apim-gateway +``` + +c. Try navigating to `https://wso2apim-publisher/carbon` from your favorite browser. + +##### 12. Scale up the Key Manager, Publisher, Store and Gateway profiles. + +Default deployment runs a single replica (or pod) for each of the profiles - Key Manager, Publisher, Store and Gateway. +To scale any of these profile deployments into any `` number of container replicas, upon your requirement, +simply run `kubectl scale` Kubernetes client command on the terminal. + +For example, the following command scales the WSO2 API Manager Gateway profile to the desired number of replicas. + +``` +kubectl scale --replicas= -f /advanced/pattern-3/apim-gateway/wso2apim-gateway-deployment.yaml +``` + +If `` is 2, you are here scaling up this deployment from 1 to 2 container replicas. diff --git a/advanced/pattern-3/pattern-3.png b/advanced/pattern-3/pattern-3.png new file mode 100644 index 00000000..cda6308b Binary files /dev/null and b/advanced/pattern-3/pattern-3.png differ diff --git a/advanced/pattern-3/scripts/README.md b/advanced/pattern-3/scripts/README.md index 192e716d..cf4555cf 100644 --- a/advanced/pattern-3/scripts/README.md +++ b/advanced/pattern-3/scripts/README.md @@ -1,7 +1,7 @@ # Kubernetes Test Resources for deployment of WSO2 API Manager with a separate Gateway and a separate Key Manager -Kubernetes Test Resources for [WSO2 API Manager deployment pattern 2](https://docs.wso2.com/display/AM260/Deployment+Patterns#DeploymentPatterns-Pattern2) contain artifacts, -which can be used to test the core Kubernetes resources provided for a deployment of WSO2 API Manager with a separate Gateway and a separate Key Manager along with WSO2 API Manager Analytics support. +Kubernetes Test Resources for [WSO2 API Manager deployment pattern 3](https://docs.wso2.com/display/AM260/Deployment+Patterns#DeploymentPatterns-Pattern3) contain artifacts, +which can be used to test the core Kubernetes resources provided for a fully distributed deployment of WSO2 API Manager with WSO2 API Manager Analytics support. ## Contents @@ -45,7 +45,7 @@ please refer the official documentation, [NGINX Ingress Controller Installation ##### 3. Setup a Network File System (NFS) to be used for persistent storage. Create and export unique directories within the NFS server instance for each Kubernetes Persistent Volume resource defined in the -`/advanced/pattern-2/volumes/persistent-volumes.yaml` file. +`/advanced/pattern-3/volumes/persistent-volumes.yaml` file. Grant ownership to `wso2carbon` user and `wso2` group, for each of the previously created directories. @@ -61,7 +61,7 @@ chmod -R 700 Update each Kubernetes Persistent Volume resource with the corresponding NFS server IP (`NFS_SERVER_IP`) and exported, NFS server directory path (`NFS_LOCATION_PATH`). -**Note**: By default, the deployment management script (i.e. `/advanced/pattern-2/scripts/deploy.sh`) is configured to deploy +**Note**: By default, the deployment management script (i.e. `/advanced/pattern-3/scripts/deploy.sh`) is configured to deploy WSO2 Identity Server as the Key Manager. If you are **not** using WSO2 Identity Server as the Key Manager, comment out the corresponding Kubernetes Persistent Volume resource. @@ -69,9 +69,9 @@ Kubernetes Persistent Volume resource. apiVersion: v1 kind: PersistentVolume metadata: - name: wso2apim-pattern-2-is-as-km-server-pv + name: wso2apim-pattern-3-is-as-km-server-pv labels: - purpose: wso2apim-pattern-2-km-shared + purpose: wso2apim-pattern-3-km-shared spec: capacity: storage: 1Gi @@ -87,7 +87,7 @@ spec: For **evaluation purposes**, -* You can use Kubernetes resources provided in the directory `/advanced/pattern-2/extras/rdbms/mysql` +* You can use Kubernetes resources provided in the directory `/advanced/pattern-3/extras/rdbms/mysql` for deploying the product databases, using MySQL in Kubernetes. However, this approach of product database deployment is **not recommended** for a production setup. @@ -100,7 +100,7 @@ for deploying the product databases, using MySQL in Kubernetes. However, this ap Provide read-write-execute permissions to other users for the created folder. Update the Kubernetes Persistent Volume resource with the corresponding NFS server IP (`NFS_SERVER_IP`) and exported, - NFS server directory path (`NFS_LOCATION_PATH`) in `/advanced/pattern-2/extras/rdbms/volumes/persistent-volumes.yaml`. + NFS server directory path (`NFS_LOCATION_PATH`) in `/advanced/pattern-3/extras/rdbms/volumes/persistent-volumes.yaml`. In a **production grade setup**, @@ -110,23 +110,23 @@ In a **production grade setup**, Provide appropriate connection URLs, corresponding to the created external databases and the relevant driver class names for the data sources defined in the following files: - * `/advanced/pattern-2/confs/apim-analytics/conf/worker/deployment.yaml` - * `/advanced/pattern-2/confs/apim-pub-store-tm-1/datasources/master-datasources.xml` - * `/advanced/pattern-2/confs/apim-pub-store-tm-2/datasources/master-datasources.xml` + * `/advanced/pattern-3/confs/apim-analytics/conf/worker/deployment.yaml` + * `/advanced/pattern-3/confs/apim-publisher/datasources/master-datasources.xml` + * `/advanced/pattern-3/confs/apim-store/datasources/master-datasources.xml` If you are using WSO2 API Manager's Key Manager profile, edit the following file. - * `/advanced/pattern-2/confs/apim-km/datasources/master-datasources.xml` + * `/advanced/pattern-3/confs/apim-km/datasources/master-datasources.xml` Else, if you are using WSO2 Identity Server as Key Manager, edit the following file. - * `/advanced/pattern-2/confs/apim-is-as-km/datasources/master-datasources.xml` + * `/advanced/pattern-3/confs/apim-is-as-km/datasources/master-datasources.xml` Please refer WSO2's [official documentation](https://docs.wso2.com/display/ADMIN44x/Configuring+master-datasources.xml) on configuring data sources. ##### 5. Deploy Kubernetes resources. -Change directory to `/advanced/pattern-2/scripts` and execute the `deploy.sh` shell script on the terminal, with the appropriate configurations as follows: +Change directory to `/advanced/pattern-3/scripts` and execute the `deploy.sh` shell script on the terminal, with the appropriate configurations as follows: ``` ./deploy.sh @@ -134,7 +134,7 @@ Change directory to `/advanced/pattern-2/scripts` and execute t **Note**: -* By default, the deployment management script (i.e. `/advanced/pattern-2/scripts/deploy.sh`) is configured to deploy +* By default, the deployment management script (i.e. `/advanced/pattern-3/scripts/deploy.sh`) is configured to deploy WSO2 Identity Server as the Key Manager. * If you desire to use WSO2 API Manager's Key Manager profile @@ -144,7 +144,6 @@ WSO2 Identity Server as the Key Manager. ``` # Kubernetes ConfigMaps for WSO2 API Manager's Key Manager profile ${KUBERNETES_CLIENT} create configmap apim-km-conf --from-file=../confs/apim-km/ - ${KUBERNETES_CLIENT} create configmap apim-km-conf-axis2 --from-file=../confs/apim-km/axis2/ ${KUBERNETES_CLIENT} create configmap apim-km-conf-datasources --from-file=../confs/apim-km/datasources/ ... @@ -164,7 +163,6 @@ WSO2 Identity Server as the Key Manager. ``` # Kubernetes ConfigMaps for WSO2 Identity Server as Key Manager ${KUBERNETES_CLIENT} create configmap apim-is-as-km-conf --from-file=../confs/apim-is-as-km/ - ${KUBERNETES_CLIENT} create configmap apim-is-as-km-conf-axis2 --from-file=../confs/apim-is-as-km/axis2/ ${KUBERNETES_CLIENT} create configmap apim-is-as-km-conf-datasources --from-file=../confs/apim-is-as-km/datasources/ ... @@ -187,7 +185,7 @@ WSO2 Identity Server as the Key Manager. ##### 6. Access Management Consoles. -Default deployment will expose `wso2apim` and `wso2apim-gateway` hosts. +Default deployment will expose `wso2apim-publisher`, `wso2apim-publisher` and `wso2apim-gateway` hosts. To access the console in the environment, @@ -200,30 +198,31 @@ a. Obtain the external IP (`EXTERNAL-IP`) of the Ingress resources by listing do e.g. ``` -NAME HOSTS ADDRESS PORTS AGE -wso2apim-ingress wso2apim 80, 443 7m -wso2apim-gateway-ingress wso2apim-gateway 80, 443 6m +NAME HOSTS ADDRESS PORTS AGE +wso2apim-ingress wso2apim-publisher,wso2apim-store 80, 443 7m +wso2apim-gateway-ingress wso2apim-gateway 80, 443 6m ``` b. Add the above host as an entry in `/etc/hosts` file as follows: ``` - wso2apim + wso2apim-publisher + wso2apim-store wso2apim-gateway ``` -c. Try navigating to `https://wso2apim/carbon` from your favorite browser. +c. Try navigating to `https://wso2apim-publisher/carbon` from your favorite browser. -##### 7. Scale up the Key Manager and Gateway profiles. +##### 7. Scale up the Key Manager, Publisher, Store and Gateway profiles. -Default deployment runs a single replica (or pod) of Key Manager profile and WSO2 API Manager Gateway. +Default deployment runs a single replica (or pod) for each of the profiles - Key Manager, Publisher, Store and Gateway. To scale any of these profile deployments into any `` number of container replicas, upon your requirement, simply run `kubectl scale` Kubernetes client command on the terminal. For example, the following command scales the WSO2 API Manager Gateway profile to the desired number of replicas. ``` -kubectl scale --replicas= -f /advanced/pattern-2/apim-gw/wso2apim-gateway-deployment.yaml +kubectl scale --replicas= -f /advanced/pattern-3/apim-gateway/wso2apim-gateway-deployment.yaml ``` -If `` is 2, you are here scaling up this deployment from 1 to 2 container replicas. \ No newline at end of file +If `` is 2, you are here scaling up this deployment from 1 to 2 container replicas.