ktimoney | 3570d5a | 2022-05-24 13:54:55 +0100 | [diff] [blame] | 1 | # |
| 2 | # ============LICENSE_START======================================================= |
| 3 | # Copyright (C) 2022 Nordix Foundation. |
| 4 | # ================================================================================ |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | # SPDX-License-Identifier: Apache-2.0 |
| 18 | # ============LICENSE_END========================================================= |
| 19 | # |
ktimoney | 90fcec9 | 2022-04-29 15:46:50 +0100 | [diff] [blame] | 20 | apiVersion: v1 |
| 21 | kind: ConfigMap |
| 22 | metadata: |
| 23 | name: kibana-config |
| 24 | namespace: logging |
| 25 | data: |
| 26 | kibana.yml: | |
| 27 | server.name: kibana |
| 28 | server.host: 0.0.0.0 |
| 29 | elasticsearch.hosts: [ "https://elasticsearch:9200" ] |
| 30 | xpack.monitoring.ui.container.elasticsearch.enabled: true |
| 31 | xpack.security.encryptionKey: 38747239hdjksdkjasdu291834zejhb38747239hdj |
| 32 | xpack.encryptedSavedObjects.encryptionKey: 38747239hdjksdkjasdu291834zejhb38747239hdj |
| 33 | elasticsearch.username: "kibana_system" |
| 34 | elasticsearch.password: "secret" |
| 35 | elasticsearch.ssl: |
| 36 | certificateAuthorities: /usr/share/kibana/config/certs/ca/ca.crt |
| 37 | verificationMode: certificate |
| 38 | --- |
| 39 | apiVersion: v1 |
| 40 | kind: ConfigMap |
| 41 | metadata: |
| 42 | name: kibana-pw-script |
| 43 | namespace: logging |
| 44 | data: |
| 45 | setup_pw.sh: | |
| 46 | #!/bin/bash |
| 47 | KIBANA_HOME=/usr/share/kibana |
| 48 | ELASTIC_PASSWORD=secret |
| 49 | KIBANA_PASSWORD=secret |
| 50 | cd $KIBANA_HOME |
| 51 | echo "Waiting for Elasticsearch availability"; |
| 52 | until curl -s --cacert /ca-dir/ca.crt https://elasticsearch:9200 | grep -q "missing authentication credentials"; \ |
| 53 | do sleep 30; done; |
| 54 | echo "Setting kibana_system password"; |
| 55 | until curl -s -X POST --cacert /ca-dir/ca.crt -u elastic:${ELASTIC_PASSWORD} -H "Content-Type: application/json" \ |
| 56 | https://elasticsearch:9200/_security/user/kibana_system/_password -d "{\"password\":\"${KIBANA_PASSWORD}\"}" | grep -q "^{}"; \ |
| 57 | do sleep 10; done; |
| 58 | echo "All done!"; |
| 59 | --- |
| 60 | apiVersion: apps/v1 |
| 61 | kind: Deployment |
| 62 | metadata: |
| 63 | name: kibana |
| 64 | namespace: logging |
| 65 | spec: |
| 66 | selector: |
| 67 | matchLabels: |
| 68 | run: kibana |
| 69 | template: |
| 70 | metadata: |
| 71 | labels: |
| 72 | run: kibana |
| 73 | spec: |
| 74 | containers: |
| 75 | - name: kibana |
| 76 | image: docker.elastic.co/kibana/kibana:8.1.2 |
| 77 | ports: |
| 78 | - containerPort: 5601 |
| 79 | name: http |
| 80 | protocol: TCP |
| 81 | volumeMounts: |
| 82 | - name : config |
| 83 | mountPath: /usr/share/kibana/config/kibana.yml |
| 84 | subPath: kibana.yml |
| 85 | readOnly: true |
| 86 | - name : kibana-ca-cert |
| 87 | mountPath: /usr/share/kibana/config/certs/ca |
| 88 | readOnly: true |
| 89 | initContainers: |
| 90 | - name: init-kibana |
| 91 | image: docker.elastic.co/kibana/kibana:8.1.2 |
| 92 | imagePullPolicy: IfNotPresent |
| 93 | command: ['/bin/bash', '-c', '/usr/share/kibana/bin/setup_pw.sh'] |
| 94 | volumeMounts: |
| 95 | - name: kibana-ca-cert |
| 96 | mountPath: "/ca-dir" |
| 97 | - name: kibana-pw-init |
| 98 | mountPath: /usr/share/kibana/bin/setup_pw.sh |
| 99 | subPath: setup_pw.sh |
| 100 | volumes: |
| 101 | - name: config |
| 102 | configMap: |
| 103 | name: kibana-config |
| 104 | - name: kibana-ca-cert |
| 105 | hostPath: |
| 106 | # Ensure the file directory is created. |
| 107 | path: /var/elasticsearch/config/certs/ca |
| 108 | type: DirectoryOrCreate |
| 109 | - name: kibana-pw-init |
| 110 | configMap: |
| 111 | name: kibana-pw-script |
| 112 | defaultMode: 0755 |
| 113 | --- |
| 114 | apiVersion: v1 |
| 115 | kind: Service |
| 116 | metadata: |
| 117 | name: kibana |
| 118 | namespace: logging |
| 119 | labels: |
| 120 | service: kibana |
| 121 | spec: |
ktimoney | 3570d5a | 2022-05-24 13:54:55 +0100 | [diff] [blame] | 122 | type: LoadBalancer |
ktimoney | 90fcec9 | 2022-04-29 15:46:50 +0100 | [diff] [blame] | 123 | selector: |
| 124 | run: kibana |
| 125 | ports: |
| 126 | - port: 5601 |
| 127 | targetPort: 5601 |