Native Kubernetes
In a native Kubernetes environment, access MarkLogic using the ClusterIP service, DNS record, or port forward.
Use the ClusterIP service
You can use the ClusterIP service to access MarkLogic within a Kubernetes cluster. The ClusterIP service includes Helm Chart installation.
Warning
The Kubernetes service does not support HTTP-level load balancing and cookie-based session affinity. To support cookie-based session affinity, use HAProxy as the load balancer.
To use the ClusterIP service, follow these steps:
Use the command
kubectl get services
to get a list of Kubernetes services. The output will look like this (the actual names may be different):NAME
TYPE
CLUSTER-IP
EXTERNAL-IP
PORT(S)
AGE
kubernetes
ClusterIP
10.96.0.1
<none>
443/TCP
1d
marklogic
ClusterIP
10.109.182.205
<none>
8000/TCP, 8001/TCP, 8002/TCP
1d
marklogic-headless
ClusterIP
None
<none>
7997/TCP,7998/TCP,7999/TCP,8000/
TCP,8001/TCP,8002/TCP
1d
The service you are looking for ends with "marklogic" and CLUSTER-IP <> None. In the example above, marklogic is the service name for the ClusterIP service. The row is shown in bold.
Additional ports
When you create a new application server on MarkLogic, you must add the new server port to additionalPorts
in the service configuration:
## @param service.additionalPorts. Additional ports exposed at the service level. ## Example: ## - name: app1 ## port: 8010 ## targetPort: 8010 ## protocol: TCP additionalPorts: - name: app-server1 port: 8010 targetPort: 8010 protocol: TCP
Use the DNS record
For each Kubernetes ClusterIP service, a DNS with this format is created:
<service-name>.<namespace-name>.svc.cluster.local
For example, if the service-name is marklogic
and the namespace-name is default
, the DNS URL to access the MarkLogic cluster is marklogic.default.svc.cluster.local
Because StatefulSet is used for the MarkLogic deployment, the DNS for individual pods is created based on the headless service:
<pod-name>.<headless-service-name>.<namespace-name>.svc.cluster.local
For example, if the pod name is marklogic-0
, then the headless service name is marklogic-headless
and the namespace-name is default
. The DNS URL to access the marklogic-0 pod is marklogic-0.marklogic.default.svc.cluster.local
.
The DNS name can be used to access a MarkLogic cluster or an individual pod if your applications are deployed in the same Kubernetes cluster.
Use the port-forward command
Use the kubectl port-forward
command to access MarkLogic outside of the Kubernetes cluster. Use it to access either a specific pod or the whole cluster.
Forward to pod
To access each pod directly, use the kubectl port-forward
command with this format:
kubectl port-forward <POD-NAME> <LOCAL-PORT>: <CONTAINER-PORT> -n <release-namespace>
For example, enter this command to forward port 8000 from the MarkLogic service to localhost:
kubectl port-forward svc/marklogic 8000:8001 -n <release-namespace>
This pod can now be accessed from http://localhost:8001.
Forward to service
To access the whole cluster, use the kubectl port-forward
command with this format:
kubectl port-forward svc/<SERVICE-NAME><LOCAL-PORT>:<CONTAINER-PORT> -n <release-namespace>
For example, enter this command to forward ports 8000 from the MarkLogic service to localhost:
kubectl port-forward svc/marklogic 8000:8000 -n <release-namespace>
This pod can now be accessed via http://localhost:8001.