|
1 | 1 | # Quick start guide
|
2 | 2 |
|
3 |
| -Use this quick start guide to create a WebLogic deployment in a Kubernetes cluster. |
| 3 | +Use this quick start guide to create a WebLogic deployment in a Kubernetes cluster with the Oracle WebLogic Kubernetes Operator. Please note that this walk-through is for demonstration purposes only, not for use in production. |
4 | 4 |
|
5 |
| -## 1. Get the images and put them into your local registry. |
| 5 | +## Prerequisite |
| 6 | +For this exercise, you’ll need a Kubernetes cluster. If you need help setting one up, check out our [cheat sheet](k8s_setup.md). |
6 | 7 |
|
7 |
| -For the Operator image: |
| 8 | +## 1. Get these images and put them into your local registry. |
| 9 | + |
| 10 | +a. Pull the operator image: |
8 | 11 | ```
|
9 | 12 | $ docker pull oracle/weblogic-kubernetes-operator:2.0
|
10 | 13 | ```
|
11 |
| -For the Traefik image: |
| 14 | +b. Pull the Traefik load balancer image: |
12 | 15 | ```
|
13 | 16 | $ docker pull traefik:latest
|
14 | 17 | ```
|
| 18 | +c. Pull the WebLogic 12.2.1.3 install image: |
| 19 | +``` |
| 20 | +$ docker pull store/oracle/weblogic:12.2.1.3 |
| 21 | +``` |
| 22 | +d. Then patch the WebLogic image according to these [instructions](https://github.com/oracle/docker-images/tree/master/OracleWebLogic/samples/12213-patch-wls-for-k8s). |
| 23 | + |
15 | 24 | ## 2. Create a Traefik (Ingress-based) load balancer.
|
16 | 25 |
|
17 |
| -Use Helm to install the [Traefik](../kubernetes/samples/charts/traefik/README.md) load balancer. |
| 26 | +Use Helm to install the [Traefik](../kubernetes/samples/charts/traefik/README.md) load balancer. Use the [values.yaml](kubernetes/samples/charts/traefik/values.yaml) in the sample but set `kubernetes.namespaces` specifically. |
18 | 27 | ```
|
19 |
| -$ helm install --name traefik-operator --namespace traefik stable/traefik |
| 28 | +$ helm install \ |
| 29 | +--name traefik-operator \ |
| 30 | +--namespace traefik \ |
| 31 | +--values <path>/values.yaml \ |
| 32 | +--set "kubernetes.namespaces={traefik}" \ |
| 33 | +stable/traefik |
20 | 34 | ```
|
21 |
| -## 3. Configure Kibana and Elasticsearch. |
22 |
| - |
23 |
| -Use the [`elasticsearch_and_kibana`](https://github.com/oracle/weblogic-kubernetes-operator/blob/develop/kubernetes/samples/scripts/elasticsearch_and_kibana.yaml) YAML file. |
| 35 | +Wait until the Traefik operator pod is running and ready. |
24 | 36 | ```
|
25 |
| -$ kubectl apply -f kubernetes/samples/scripts/elasticsearch_and_kibana.yaml |
| 37 | +$ kubectl -n traefik get pod -w |
26 | 38 | ```
|
| 39 | +## 3. Install the operator. |
27 | 40 |
|
28 |
| -## 4. Install the operator. |
29 |
| - |
30 |
| -* Create a namespace for the operator: |
| 41 | +a. Create a namespace for the operator: |
31 | 42 | ```
|
32 |
| -$ kubectl create namespace weblogic-operator |
| 43 | +$ kubectl create namespace sample-weblogic-operator-ns |
33 | 44 | ```
|
34 |
| -* Create a `serviceAccount` for the operator's namespace. If not specified, it defaults to `default` (for example, the namespace's default service account). |
35 |
| -* Invoke the script to generate the credentials for the operator and add it to the operator YAML file (you can keep all the default values). |
36 |
| -* Create the operator using `helm install`, and passing in the namespace, service account, and location of Elasticsearch. |
37 |
| - * Helm is used to deploy the operator in a Kubernetes cluster. |
38 |
| - * Use the `helm install` command to install the operator Helm chart, passing in the `values.yaml`. |
39 |
| - * Edit the `values.yaml` file to update the information such as the operator's namespace and service account. |
| 45 | +b. Create a service account for the operator in the operator's namespace: |
40 | 46 | ```
|
41 |
| - $ helm install kubernetes/charts/weblogic-operator --name my-operator --namespace weblogic-operator-ns --values values.yaml --wait |
| 47 | +$ kubectl create serviceaccount -n sample-weblogic-operator-ns sample-weblogic-operator-sa |
42 | 48 | ```
|
| 49 | +c. Use ` helm` to install and start the operator: |
43 | 50 |
|
44 |
| -## 5. Prepare your environment for a domain. |
| 51 | +``` |
| 52 | +$ helm install \ |
| 53 | + --name sample-weblogic-operator \ |
| 54 | + --namespace sample-weblogic-operator-ns \ |
| 55 | + --set serviceAccount=sample-weblogic-operator-sa \ |
| 56 | + --set "domainNamespaces={}" \ |
| 57 | + -- wait \ |
| 58 | + kubernetes/charts/weblogic-operator |
| 59 | +``` |
| 60 | +d. Verify that the operator is up and running by viewing the operator pod's log: |
45 | 61 |
|
46 |
| -* Optionally, create a domain namespace if you want to persist the domain home in a PV: |
47 | 62 | ```
|
48 |
| -$ kubectl create namespace domain1-ns |
| 63 | +$ kubectl log -n sample-weblogic-operator-ns -c weblogic-operator deployments/weblogic-operator |
49 | 64 | ```
|
50 |
| -* Create the Kubernetes secrets for the Administration Server boot credentials by invoking the [`create-weblogic-credentials` script](https://github.com/oracle/weblogic-kubernetes-operator/blob/develop/kubernetes/samples/scripts/create-weblogic-domain/create-weblogic-credentials.sh). |
51 | 65 |
|
52 |
| -* Create a PV & PVC for the domain: |
53 |
| - * Find the `create_pv_pvc.sh script` and YAML files you'll need to edit to create the PV and PVC, in the https://github.com/oracle/weblogic-kubernetes-operator/tree/develop/kubernetes/samples/scripts/create-weblogic-domain-pv-pvc directory. |
54 |
| -* Edit the operator YAML file to add the domain namespace, then do a `helm upgrade`. |
55 |
| -* Create the Docker image for the domain home in the image or use the WebLogic binary image. |
56 |
| - * Run WLST to create the domain in PV (remember to apply the patch). |
| 66 | +## 4. Prepare your environment for a domain. |
57 | 67 |
|
58 |
| -## 6. Create a domain. |
| 68 | +a. Create a namespace that can host one or more domains: |
59 | 69 |
|
60 |
| -* Edit the domain YAML file (can the defaults be used?). |
61 |
| -* Create the domain home for the domain. |
62 |
| - * For a domain home on a PV, first pull the WebLogic 12.2.1.3 install image into a local repository: |
| 70 | +``` |
| 71 | +$ kubectl create namespace sample-domains-ns1 |
| 72 | +``` |
| 73 | +b. Use `helm` to configure the operator to manage domains in this namespace: |
63 | 74 |
|
64 |
| -``` |
65 |
| -$ docker pull store/oracle/weblogic:12.2.1.3-dev |
66 | 75 | ```
|
67 |
| - * For reference, see the [domain home on PV README](https://github.com/oracle/weblogic-kubernetes-operator/blob/develop/kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/README.md). |
68 |
| - * The `create-domain.sh` will: |
69 |
| - * Create a directory for the generated Kubernetes YAML files for this domain. The pathname is `/path/to/weblogic-operator-output-directory/weblogic-domains/`. |
70 |
| - * Create a Kubernetes job that will start up a utility WebLogic Server container and run offline WLST scripts, or WebLogic Deploy Tool (WDT) scripts, to create the domain on the shared storage. |
71 |
| - * Run and wait for the job to finish. |
72 |
| - * Create a Kubernetes domain resource YAML file, `domain-custom-resource.yaml`, in the directory that is created above. You can use this YAML file to create the Kubernetes resource using the `kubectl create -f` or `kubectl apply -f` command: |
| 76 | +$ helm upgrade \ |
| 77 | + --reuse-values \ |
| 78 | + --set "domainNamespaces={sample-domains-ns1}" \ |
| 79 | + --wait \ |
| 80 | + sample-weblogic-operator \ |
| 81 | + kubernetes/charts/weblogic-operator |
73 | 82 |
|
74 | 83 | ```
|
75 |
| - ./create-domain.sh |
76 |
| - -i create-domain-inputs.yaml |
77 |
| - -o /path/to/output-directory |
| 84 | +c. Configure Traefik to manage Ingresses created in this namespace: |
| 85 | +``` |
| 86 | +$ helm upgrade \ |
| 87 | + --reuse-values \ |
| 88 | + --set "kubernetes.namespaces={traefik,sample-domains-ns1}" \ |
| 89 | + traefik-operator \ |
| 90 | + stable/traefik |
| 91 | +``` |
| 92 | +d. Wait until the Traefik operator pod finish restart. |
| 93 | +``` |
| 94 | +$ kubectl -n traefik get pod -w |
78 | 95 | ```
|
79 | 96 |
|
80 |
| -* For a domain home in image, use the sample in the Docker GitHub project. |
81 |
| - |
82 |
| -* Optionally, create a configuration overrides template and any additional Kubernetes secrets it needs (for example, to override the domain home configuration of a database URL, username, and password). |
| 97 | +## 5. Create a domain in the domain namespace. |
83 | 98 |
|
84 |
| -* Create a domain resource in the domain namespace. |
85 |
| - * Specify the following information: domain UID, service account, secret name, the domain home details, and optionally, the configuration overrides template name. |
| 99 | +a. Create a new image with a domain home by running the [`create-domain`](../kubernetes/samples/scripts/create-weblogic-domain/domain-home-in-image/create-domain.sh) script. Follow the directions in the [README](../kubernetes/samples/scripts/create-weblogic-domain/domain-home-in-image/README.md) file, including: |
86 | 100 |
|
87 |
| -* Configure the operator to know about the domain. |
88 |
| - * Edit the operator `values.yaml` file to add the namespace of the domain: |
| 101 | +* Modifying the sample `inputs.yaml` file with the `domainUID` (`sample-domain1`) and domain namespace (`sample-domains-ns1`). |
89 | 102 |
|
| 103 | +* Creating Kubernetes secrets `username` and `password` of the admin account using the [`create-weblogic-credentials`](../kubernetes/samples/scripts/create-weblogic-domain-credentials/create-weblogic-credentials.sh) script. |
90 | 104 | ```
|
91 |
| -$ helm update kubernetes/charts/weblogic-operator --name my-operator --namespace weblogic-operator-ns --values values.yaml --wait |
| 105 | +cd ../kubernetes/samples/scripts/create-weblogic-domain-credentials |
| 106 | +./create-weblogic-credentials.sh -u <username> -p <password> -n sample-domain1-ns -d sample-domain1 |
92 | 107 | ```
|
93 | 108 |
|
94 |
| -* Configure the Traefik load balancer to manage the domain as follows: |
95 |
| - * Create an Ingress for the domain in the domain namespace (it contains the routing rules for the domain): |
| 109 | +b. Confirm that the operator started the servers for the domain: |
| 110 | +``` |
| 111 | +$ kubectl get po -n sample-domain1-ns |
| 112 | +``` |
| 113 | +* Use `kubectl` to show that the domain resource was created: |
| 114 | +``` |
| 115 | +$ kubectl describe domain sample-domain1 -n sample-domain1-ns |
| 116 | +``` |
| 117 | +* Verify that the operator's pod is running, by listing the pods in the operator's namespace. You should see one for the operator. |
| 118 | +``` |
| 119 | +kubectl get pods -n sample-weblogic-operator1-ns |
| 120 | +``` |
96 | 121 |
|
| 122 | +c. Create an Ingress for the domain, in the domain namespace, by using the [sample](../kubernetes/samples/charts/ingress-per-domain/README.md) Helm chart: |
| 123 | +* Use `helm install`, specifying the `domainUID` (`sample-domain1`) and domain namespace (`sample-domains-ns1`). |
97 | 124 | ```
|
98 | 125 | $ cd kubernetes/samples/charts
|
99 | 126 | $ helm install ingress-per-domain --name domain1-ingress --values values.yaml
|
100 | 127 | ```
|
101 | 128 |
|
102 |
| -(At this point, do they have a WebLogic Kubernetes deployment in a Kubernetes cluster? If so, we have to give them something to look at, to verify their results.) |
103 |
| - |
104 |
| -## 7. Remove a domain. |
| 129 | +d. Confirm that the load balancer noticed the new Ingress and is successfully routing to the domain's server pods: |
| 130 | +``` |
| 131 | +$ curl http://${HOSTNAME}:30305/sample-domain1/ |
| 132 | +``` |
105 | 133 |
|
106 |
| -* Remove the domain's Kubernetes resources (domain, secrets, ingress, ...). |
107 |
| - * To remove the domain and all the Kubernetes resources (labeled with the `domainUID`), invoke the [delete domain resources script](https://github.com/oracle/weblogic-kubernetes-operator/blob/develop/kubernetes/samples/scripts/delete-weblogic-domain-resources.sh). |
108 | 134 |
|
109 |
| - * The operator will notice that the domain's domain resource has been removed and will then kill the pods. |
110 |
| -* Configure the Traefik load balancer to stop managing the domain. |
111 |
| - * If you have configured Traefik to manage the domain's namespace (instead of the default: all namespaces), then edit the Traefik YAML file to remove the domain namespace and do a `helm update`: |
| 135 | +## 6. Remove the domain. |
112 | 136 |
|
| 137 | +a. Remove the domain's Ingress by using `helm`: |
113 | 138 | ```
|
114 |
| -helm update --name traefik-operator --namespace traefik (default values in yaml) |
115 |
| -or |
116 |
| -helm update --name traefik-operator --namespace traefik --values values.yaml stable/traefik |
| 139 | +helm delete --purge domain1-ingress |
117 | 140 | ```
|
| 141 | +b. Remove the domain resource by using the sample [`delete-weblogic-domain-resources`](../kubernetes/samples/scripts/delete-domain/delete-weblogic-domain-resources.sh) script. |
118 | 142 |
|
119 |
| -* Remove the domain home if it's on a PV. |
| 143 | +c. Use `kubectl` to confirm that the server pods and domain resource are gone. |
120 | 144 |
|
121 |
| -## 8. Remove the domain namespace. |
| 145 | +## 7. Remove the domain namespace. |
| 146 | +a. Configure the Traefik load balancer to stop managing the Ingresses in the domain namespace: |
122 | 147 |
|
123 |
| -* Configure the Traefik load balancer to stop managing the domain namespace. Use `helm upgrade` to remove the domain namespace from the list of namespaces. |
124 |
| -* Configure the operator to stop managing the domain. Use `helm upgrade` to remove the domain namespace from the list of domain namespaces. |
125 |
| -* Remove the PV & PVC for the domain namespace. |
126 |
| -* Remove the domain namespace: |
127 | 148 | ```
|
128 |
| -$ kubectl delete namespaces domain1-ns |
| 149 | +$ helm upgrade \ |
| 150 | + --reuse-values \ |
| 151 | + --set "kubernetes.namespaces={traefik}" \ |
| 152 | + traefik-operator \ |
| 153 | + stable/traefik |
129 | 154 | ```
|
130 | 155 |
|
131 |
| -## 9. Remove the operator. |
132 |
| - |
133 |
| -* Remove the operator: |
| 156 | +b. Configure the operator to stop managing the domain. |
134 | 157 |
|
135 | 158 | ```
|
136 |
| -helm delete --purge my-operator |
| 159 | +$ helm upgrade \ |
| 160 | + --reuse-values \ |
| 161 | + --set "domainNamespaces={}" \ |
| 162 | + --wait \ |
| 163 | + sample-weblogic-operator \ |
| 164 | + kubernetes/charts/weblogic-operator |
137 | 165 | ```
|
138 |
| -* Remove the operator namespace: |
| 166 | +c. Delete the domain namespace: |
139 | 167 |
|
140 | 168 | ```
|
141 |
| -$ kubectl delete namespaces weblogic-operator-ns |
| 169 | +$ kubectl delete namespace sample-domains-ns1 |
142 | 170 | ```
|
143 | 171 |
|
144 |
| -## 10. Remove other resources. |
145 |
| - |
146 |
| -* Optionally, remove Kibana and Elasticsearch: |
| 172 | +## 8. Remove the operator. |
147 | 173 |
|
| 174 | +a. Remove the operator: |
148 | 175 | ```
|
149 |
| -$ kubectl apply -f kubernetes/samples/scripts/elasticsearch_and_kibana.yaml |
| 176 | +helm delete --purge sample-weblogic-operator |
150 | 177 | ```
|
151 |
| -* Remove the Traefik load balancer: |
| 178 | +b. Remove the operator's namespace: |
152 | 179 |
|
153 | 180 | ```
|
154 |
| -helm delete --purge |
| 181 | +$ kubectl delete namespace sample-weblogic-operator-ns |
| 182 | +``` |
| 183 | +## 9. Remove the load balancer. |
| 184 | +a. Remove the Traefik load balancer: |
| 185 | +``` |
| 186 | +helm delete --purge traefik-operator |
155 | 187 | ```
|
156 |
| -* Remove the Traefik namespace: |
| 188 | +b. Remove the Traefik namespace: |
157 | 189 |
|
158 | 190 | ```
|
159 |
| -$ kubectl delete namespaces traefik |
| 191 | +$ kubectl delete namespace traefik |
160 | 192 | ```
|
0 commit comments