How do I configure Kibana with ConfigMaps in Kubernetes?
In this guide, we will configure Kibana in a Kubernetes cluster using ConfigMaps. ConfigMaps in Kubernetes allow you to decouple configuration artifacts from image content to keep containerized applications portable. We will create a ConfigMap to store Kibana’s configuration, and then we will deploy Kibana using this configuration.
import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";
// Create a ConfigMap to store Kibana configuration
const kibanaConfigMap = new k8s.core.v1.ConfigMap("kibana-config", {
metadata: {
name: "kibana-config",
namespace: "default",
},
data: {
"kibana.yml": `
server.name: kibana
server.host: "0"
elasticsearch.hosts: [ "http://elasticsearch:9200" ]
`,
},
});
// Deploy Kibana using the ConfigMap
const kibanaDeployment = new k8s.apps.v1.Deployment("kibana-deployment", {
metadata: {
name: "kibana",
namespace: "default",
},
spec: {
replicas: 1,
selector: {
matchLabels: {
app: "kibana",
},
},
template: {
metadata: {
labels: {
app: "kibana",
},
},
spec: {
containers: [
{
name: "kibana",
image: "docker.elastic.co/kibana/kibana:7.10.0",
ports: [
{
containerPort: 5601,
},
],
volumeMounts: [
{
name: "config-volume",
mountPath: "/usr/share/kibana/config/kibana.yml",
subPath: "kibana.yml",
},
],
},
],
volumes: [
{
name: "config-volume",
configMap: {
name: "kibana-config",
},
},
],
},
},
},
});
// Create a Service to expose Kibana
const kibanaService = new k8s.core.v1.Service("kibana-service", {
metadata: {
name: "kibana",
namespace: "default",
},
spec: {
selector: {
app: "kibana",
},
ports: [
{
port: 5601,
targetPort: 5601,
},
],
type: "LoadBalancer",
},
});
// Export the Kibana service URL
export const kibanaUrl = kibanaService.status.loadBalancer.ingress[0].hostname;
Key Points
- ConfigMap: Stores the Kibana configuration file (
kibana.yml
). - Deployment: Defines the Kibana deployment, using the ConfigMap for configuration.
- Service: Exposes Kibana using a LoadBalancer service.
Summary
In this guide, we configured Kibana using a ConfigMap in Kubernetes. We created a ConfigMap to store the Kibana configuration, deployed Kibana using this ConfigMap, and exposed Kibana with a LoadBalancer service. This approach decouples configuration from the application, making it more manageable and portable.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.