Discover the origins and reasons behind the /healthz convention for application health checks in Kubernetes.
This guide provides a step-by-step approach to deploying Apache Solr on a Kubernetes cluster using a YAML configuration file. We will define a deployment for Solr, specify the desired image and resource limits, and configure environment variables. To make Solr accessible, we will create a service and expose it within the cluster. Finally, we will deploy the configuration to Kubernetes and verify access to the Solr dashboard.
Define your Solr deployment:
apiVersion: apps/v1
kind: Deployment
# ... rest of your deployment configuration
Specify the Solr image and resources:
spec:
template:
spec:
containers:
- name: solr
image: solr:8.11.2
resources:
limits:
memory: "1Gi"
cpu: "1"
Configure Solr environment variables:
env:
- name: SOLR_HOME
value: /opt/solr/server
- name: SOLR_OPTS
value: -Dsolr.log.dir=/var/solr/logs
Create a Service to expose Solr:
apiVersion: v1
kind: Service
# ... service configuration
spec:
selector:
app: solr
ports:
- protocol: TCP
port: 8983
targetPort: 8983
Deploy to Kubernetes:
kubectl apply -f your-solr-deployment.yaml
Access the Solr dashboard:
kubectl get svc solr
http://<service-ip>:<port>/solr
This code describes how to deploy a single-replica Solr instance on a Kubernetes cluster. It defines a Deployment that uses the solr:8.11.2 image and sets resource limits, environment variables, and a service on port 8983. A Service is then created to expose the Solr deployment, allowing access to the Solr dashboard. The deployment and service are applied to the cluster using kubectl. Finally, instructions are provided for accessing the Solr dashboard using the service IP and port.
This example demonstrates deploying Solr on Kubernetes using a Deployment and Service.
1. Define the Solr Deployment (solr-deployment.yaml):
apiVersion: apps/v1
kind: Deployment
metadata:
name: solr
spec:
replicas: 1
selector:
matchLabels:
app: solr
template:
metadata:
labels:
app: solr
spec:
containers:
- name: solr
image: solr:8.11.2
resources:
limits:
memory: "1Gi"
cpu: "1"
env:
- name: SOLR_HOME
value: /opt/solr/server
- name: SOLR_OPTS
value: -Dsolr.log.dir=/var/solr/logs
ports:
- containerPort: 8983
2. Create the Solr Service (solr-service.yaml):
apiVersion: v1
kind: Service
metadata:
name: solr
spec:
selector:
app: solr
ports:
- protocol: TCP
port: 8983
targetPort: 8983
3. Deploy to Kubernetes:
kubectl apply -f solr-deployment.yaml
kubectl apply -f solr-service.yaml
4. Access the Solr Dashboard:
kubectl get svc solr
This command will output the service details, including the service IP and port. Use these details to access the Solr dashboard:
http://<service-ip>:<port>/solr
Explanation:
solr:8.11.2
image and sets resource limits. Environment variables SOLR_HOME
and SOLR_OPTS
configure Solr's home directory and logging.kubectl get svc solr
and access the dashboard using the provided URL.This example provides a basic Solr deployment. You can customize it further by adding features like persistent volumes for data persistence, ingress for external access, and more.
General:
solr:8.11.2
) instead of latest
for better control and reproducibility.memory
and cpu
limits based on your expected workload and cluster resources.replicas
in the Deployment to have multiple Solr instances. Consider using a StatefulSet for managing stateful data in a clustered Solr setup.Deployment:
Service:
Additional Considerations:
Customization:
By considering these notes, you can create a more robust, secure, and scalable Solr deployment on Kubernetes.
This document outlines the steps to deploy Apache Solr on a Kubernetes cluster using a YAML configuration file.
Here's a breakdown of the process:
solr:8.11.2
in this case) and allocates CPU and memory resources for the container.SOLR_HOME
(Solr's installation directory) and SOLR_OPTS
(for customizing Solr's behavior, like setting the log directory).kubectl apply
command deploys the configuration defined in the YAML file to the Kubernetes cluster.kubectl get svc solr
. Access the Solr dashboard in your web browser using this information (e.g., http://<service-ip>:<port>/solr
).This approach provides a structured and repeatable way to deploy and manage Solr on Kubernetes, ensuring that your search service is scalable and highly available.
This guide provides a comprehensive overview of deploying a single-instance Apache Solr on a Kubernetes cluster. By leveraging Kubernetes Deployments and Services, we can ensure the application's scalability and accessibility. The provided YAML configurations offer a starting point for defining the Solr deployment, specifying resource limits, and exposing the service. Remember to tailor these configurations to your specific needs, considering factors like persistent storage, security, and resource allocation. With this foundation, you can effectively deploy and manage your Solr instance within a Kubernetes environment.