반응형

 

 

이러다 설치만 장인되겠다

해당 글은 helm chart로 설치하는 정리 가이드이다.

가이드 작성시 상세 설명은 따로 하지 않는다. 

 

OpenSearch Operator로 설치는 가이드보면 설치자체는 어려운것은 없으나, 인증서 부분에서 상당히 복잡하기 때문에 아래 글 참고한다.

2024.11.28 - [Develop/OpenSearch / FluentBit] - OpenSearch Operator Certificate 설정

 

Single Node 로 설치는 아래 글 참고한다.

2025.03.06 - [Develop/OpenSearch / FluentBit] - OpenSearch SingleNode

 

OpenSearch FluentBit 연동은 아래 글 참고한다.

2024.11.03 - [Develop/OpenSearch / FluentBit] - OpenSearch, Dashboard 설치 및 Fluent-Bit OpenSeach 연동

 

OpenSearch Operator Coordinator 설치는 아래 글 참고한다.

2025.02.18 - [Develop/OpenSearch / FluentBit] - OpenSearch Operator Coordinator

 

 

1. Demo 인증서가아닌 self 인증서를 생성한다. 인증서가 있으면 건너 뛴다.

# root ca 생성
openssl genrsa -out root-ca-key.pem 2048
openssl req -new -x509 -sha256 -key root-ca-key.pem -subj "/CN=opensearch" -out root-ca.pem -days 3650

# OpenSearch Operator가 OpenSearch Cluster를 관리하는 관리자 인증서
openssl genrsa -out admin-key-temp.pem 2048
openssl pkcs8 -inform PEM -outform PEM -in admin-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out admin-key.pem
openssl req -new -key admin-key.pem -subj "/CN=opensearch-admin" -out admin.csr
openssl x509 -req -in admin.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out admin.pem -days 3650

# Node간 DNS 통신을 위해 subjectAltName 생성
echo 'subjectAltName=DNS:opensearch-cluster-master,DNS:opensearch-cluster-master.logging,DNS:opensearch-cluster-master.logging.svc,DNS:opensearch-cluster-master.logging.svc.cluster.local' > san.ext

# OpenSearch Node간 인증서
openssl genrsa -out node-key-temp.pem 2048
openssl pkcs8 -inform PEM -outform PEM -in node-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out node-key.pem
openssl req -new -key node-key.pem -subj "/CN=opensearch-cluster-master" -out node.csr
openssl x509 -req -in node.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out node.pem -days 3650 -extfile san.ext

# OpenSearch yaml에 등록할 인증서 파일들 secret으로 생성
kubectl create ns logging
kubectl create secret generic opensearch-cert --from-file=root-ca.pem=root-ca.pem --from-file=admin.pem=admin.pem --from-file=admin-key.pem=admin-key.pem \
--from-file=root-ca.pem=root-ca.pem --from-file=node.pem=node.pem --from-file=node-key.pem=node-key.pem -n logging

 

 

2. helm repo 추가

공식 가이드에 나온대로 진행한다.

helm repo add opensearch https://opensearch-project.github.io/helm-charts
helm repo upadte

 

 

3. OpenSearch에 사용할 관리자 계정 secret 생성

아래 링크에서 가져온 샘플이다. 필요에 따라 수정해서 사용하면 됨.

https://github.com/opensearch-project/opensearch-k8s-operator/blob/main/opensearch-operator/examples/securityconfig-secret.yaml

apiVersion: v1
kind: Secret
metadata:
  name: securityconfig-secret
type: Opaque
stringData:
      action_groups.yml: |-
         _meta:
           type: "actiongroups"
           config_version: 2
      internal_users.yml: |-
        _meta:
          type: "internalusers"
          config_version: 2
        admin:
          hash: "$2y$12$lJsHWchewGVcGlYgE3js/O4bkTZynETyXChAITarCHLz8cuaueIyq"
          reserved: true
          backend_roles:
          - "admin"
          description: "admin user"
        dashboarduser:
          hash: "$2a$12$4AcgAt3xwOWadA5s5blL6ev39OXDNhmOesEoo33eZtrq2N0YrU3H."
          reserved: true
          description: "OpenSearch Dashboards user"
      nodes_dn.yml: |-
        _meta:
          type: "nodesdn"
          config_version: 2
      whitelist.yml: |-
        _meta:
          type: "whitelist"
          config_version: 2
      tenants.yml: |-
        _meta:
          type: "tenants"
          config_version: 2
      roles_mapping.yml: |-
        _meta:
          type: "rolesmapping"
          config_version: 2
        all_access:
          reserved: false
          backend_roles:
          - "admin"
          description: "Maps admin to all_access"
        own_index:
          reserved: false
          users:
          - "*"
          description: "Allow full access to an index named like the username"
        readall:
          reserved: false
          backend_roles:
          - "readall"
        manage_snapshots:
          reserved: false
          backend_roles:
          - "snapshotrestore"
        dashboard_server:
          reserved: true
          users:
          - "dashboarduser"
      roles.yml: |-
        _meta:
          type: "roles"
          config_version: 2
        dashboard_read_only:
          reserved: true
        security_rest_api_access:
          reserved: true
        # Allows users to view monitors, destinations and alerts
        alerting_read_access:
          reserved: true
          cluster_permissions:
            - 'cluster:admin/opendistro/alerting/alerts/get'
            - 'cluster:admin/opendistro/alerting/destination/get'
            - 'cluster:admin/opendistro/alerting/monitor/get'
            - 'cluster:admin/opendistro/alerting/monitor/search'
        # Allows users to view and acknowledge alerts
        alerting_ack_alerts:
          reserved: true
          cluster_permissions:
            - 'cluster:admin/opendistro/alerting/alerts/*'
        # Allows users to use all alerting functionality
        alerting_full_access:
          reserved: true
          cluster_permissions:
            - 'cluster_monitor'
            - 'cluster:admin/opendistro/alerting/*'
          index_permissions:
            - index_patterns:
                - '*'
              allowed_actions:
                - 'indices_monitor'
                - 'indices:admin/aliases/get'
                - 'indices:admin/mappings/get'
        # Allow users to read Anomaly Detection detectors and results
        anomaly_read_access:
          reserved: true
          cluster_permissions:
            - 'cluster:admin/opendistro/ad/detector/info'
            - 'cluster:admin/opendistro/ad/detector/search'
            - 'cluster:admin/opendistro/ad/detectors/get'
            - 'cluster:admin/opendistro/ad/result/search'
            - 'cluster:admin/opendistro/ad/tasks/search'
            - 'cluster:admin/opendistro/ad/detector/validate'
            - 'cluster:admin/opendistro/ad/result/topAnomalies'
        # Allows users to use all Anomaly Detection functionality
        anomaly_full_access:
          reserved: true
          cluster_permissions:
            - 'cluster_monitor'
            - 'cluster:admin/opendistro/ad/*'
          index_permissions:
            - index_patterns:
                - '*'
              allowed_actions:
                - 'indices_monitor'
                - 'indices:admin/aliases/get'
                - 'indices:admin/mappings/get'
        # Allows users to read Notebooks
        notebooks_read_access:
          reserved: true
          cluster_permissions:
            - 'cluster:admin/opendistro/notebooks/list'
            - 'cluster:admin/opendistro/notebooks/get'
        # Allows users to all Notebooks functionality
        notebooks_full_access:
          reserved: true
          cluster_permissions:
            - 'cluster:admin/opendistro/notebooks/create'
            - 'cluster:admin/opendistro/notebooks/update'
            - 'cluster:admin/opendistro/notebooks/delete'
            - 'cluster:admin/opendistro/notebooks/get'
            - 'cluster:admin/opendistro/notebooks/list'
        # Allows users to read observability objects
        observability_read_access:
          reserved: true
          cluster_permissions:
            - 'cluster:admin/opensearch/observability/get'
        # Allows users to all Observability functionality
        observability_full_access:
          reserved: true
          cluster_permissions:
            - 'cluster:admin/opensearch/observability/create'
            - 'cluster:admin/opensearch/observability/update'
            - 'cluster:admin/opensearch/observability/delete'
            - 'cluster:admin/opensearch/observability/get'
        # Allows users to read and download Reports
        reports_instances_read_access:
          reserved: true
          cluster_permissions:
            - 'cluster:admin/opendistro/reports/instance/list'
            - 'cluster:admin/opendistro/reports/instance/get'
            - 'cluster:admin/opendistro/reports/menu/download'
        # Allows users to read and download Reports and Report-definitions
        reports_read_access:
          reserved: true
          cluster_permissions:
            - 'cluster:admin/opendistro/reports/definition/get'
            - 'cluster:admin/opendistro/reports/definition/list'
            - 'cluster:admin/opendistro/reports/instance/list'
            - 'cluster:admin/opendistro/reports/instance/get'
            - 'cluster:admin/opendistro/reports/menu/download'
        # Allows users to all Reports functionality
        reports_full_access:
          reserved: true
          cluster_permissions:
            - 'cluster:admin/opendistro/reports/definition/create'
            - 'cluster:admin/opendistro/reports/definition/update'
            - 'cluster:admin/opendistro/reports/definition/on_demand'
            - 'cluster:admin/opendistro/reports/definition/delete'
            - 'cluster:admin/opendistro/reports/definition/get'
            - 'cluster:admin/opendistro/reports/definition/list'
            - 'cluster:admin/opendistro/reports/instance/list'
            - 'cluster:admin/opendistro/reports/instance/get'
            - 'cluster:admin/opendistro/reports/menu/download'
        # Allows users to use all asynchronous-search functionality
        asynchronous_search_full_access:
          reserved: true
          cluster_permissions:
            - 'cluster:admin/opendistro/asynchronous_search/*'
          index_permissions:
            - index_patterns:
                - '*'
              allowed_actions:
                - 'indices:data/read/search*'
        # Allows users to read stored asynchronous-search results
        asynchronous_search_read_access:
          reserved: true
          cluster_permissions:
            - 'cluster:admin/opendistro/asynchronous_search/get'
        # Allows user to use all index_management actions - ism policies, rollups, transforms
        index_management_full_access:
          reserved: true
          cluster_permissions:
            - "cluster:admin/opendistro/ism/*"
            - "cluster:admin/opendistro/rollup/*"
            - "cluster:admin/opendistro/transform/*"
          index_permissions:
            - index_patterns:
                - '*'
              allowed_actions:
                - 'indices:admin/opensearch/ism/*'
        # Allows users to use all cross cluster replication functionality at leader cluster
        cross_cluster_replication_leader_full_access:
          reserved: true
          index_permissions:
            - index_patterns:
                - '*'
              allowed_actions:
                - "indices:admin/plugins/replication/index/setup/validate"
                - "indices:data/read/plugins/replication/changes"
                - "indices:data/read/plugins/replication/file_chunk"
        # Allows users to use all cross cluster replication functionality at follower cluster
        cross_cluster_replication_follower_full_access:
          reserved: true
          cluster_permissions:
            - "cluster:admin/plugins/replication/autofollow/update"
          index_permissions:
            - index_patterns:
                - '*'
              allowed_actions:
                - "indices:admin/plugins/replication/index/setup/validate"
                - "indices:data/write/plugins/replication/changes"
                - "indices:admin/plugins/replication/index/start"
                - "indices:admin/plugins/replication/index/pause"
                - "indices:admin/plugins/replication/index/resume"
                - "indices:admin/plugins/replication/index/stop"
                - "indices:admin/plugins/replication/index/update"
                - "indices:admin/plugins/replication/index/status_check"
      config.yml: |-
        _meta:
          type: "config"
          config_version: "2"
        config:
          dynamic:
            http:
              anonymous_auth_enabled: false
            authc:
              basic_internal_auth_domain:
                http_enabled: true
                transport_enabled: true
                order: "4"
                http_authenticator:
                  type: basic
                  challenge: true
                authentication_backend:
                  type: intern

 

 

4. OpenSearch Dashboards에 등록할 관리자 계정 Secret생성

vi admin-secret.yaml
apiVersion: v1
kind: Secret
metadata:
  name: admin-credentials
  namespace: logging
type: Opaque
data:
  username: YWRtaW4= # admin
  password: YWRtaW4xMjM=  # admin123
  
kubectl apply -f admin-secret.yaml

 

 

5. OpenSearch 설치

기본적으로 helm chart에 values.yaml 을 수정해서 적용하는 것을 추천하나, 이번엔 바로 적용을 해본다.

인증서를 mount하고, opensearch.yml을 정의하고 securityConfigSecret을 추가하여 관리자 계정을 생성한다.

helm install opensearch-cluster opensearch/opensearch \
--namespace logging --create-namespace
--set clusterName='opensearch-cluster'
--set persistence.storageClass=nfs \ # StorgeClass 가 있으면 설정 없으면 삭제
--set persistence.enabled=false \ # EmptyDir로 실행하고 싶으면 설정 그게아니라면 따로 PV설정필요
# 기본적으로 아래로 적용
--set-json 'extraEnvs=[{"name": "DISABLE_INSTALL_DEMO_CONFIG", "value": "true"}] \
# SingleNode로 설치시 lifecycle 이용할려면 아래로 적용
--set-json 'extraEnvs=[{"name": "DISABLE_INSTALL_DEMO_CONFIG", "value": "true"}
{"name": "OPENSEARCH_USERNAME", "valueFrom": {"secretKeyRef": {"key": "username",
"name": "admin-credentials-secret"}}},
{"name": "OPENSEARCH_PASSWORD", "valueFrom": {"secretKeyRef": {"key": "password",
"name": "admin-credentials-secret"}}}]' \
--set-json 'extraVolumes=[{"name": "certs-secret" "secret": {"defaultMode": 384,
"secretName": "opensearch-cert"}}] \
--set-json 'extraVolumeMounts=[{"mountPath": "/usr/share/opensearch/config/certs",
"name": "certs-secret"}]' \
--set config.opensearch.yml="cluster.name: opensearch-cluster
plugins.security.ssl.transport.pemcert_filepath: certs/node.pem
plugins.security.ssl.transport.pemkey_filepath: certs/node-key.pem
plugins.security.ssl.transport.pemtrustedcas_filepath: certs/root-ca.pem
plugins.security.ssl.http.pemcert_filepath: certs/node.pem
plugins.security.ssl.http.pemkey_filepath: certs/node-key.pem
plugins.security.ssl.http.pemtrustedcas_filepath: certs/root-ca.pem
plugins.security.allow_unsafe_democertificates: false
plugins.security.allow_default_init_securityindex: true
plugins.security.authz.admin_dn: ['CN=opensearch-admin']
plugins.security.nodes_dn: ['CN=opensearch*']
plugins.security.audit.type: internal_opensearch
plugins.security.enable_snapshot_restore_privilege: true
plugins.security.check_snapshot_restore_write_privilege: true
plugins.security.restapi.roles_enabled: [all_access, security_rest_api_access]
plugins.security.system_indices.enabled: true
plugins.security.system_indices.indices: ['.opendistro-alerting-config', '.opendistro-alerting-alert*', '.opendistro-anomaly-results*', '.opendistro-anomaly-detector*', '.opendistro-anomaly-checkpoints', '.opendistro-anomaly-detection-state', '.opendistro-reports-*", ".opendistro-notifications-*', '.opendistro-notebooks', '.opendistro-asynchronous-search-response*']
node.max_local_storage_nodes: 3' # Single Node 이면 삭제하고 따옴표 주의
--set securityConfig.config.securityConfigSecret=securityconfig-secret"

 

기타.

https://opensearch.org/docs/latest/security/configuration/system-indices/

를 확인하면 관리자 계정으로도 사용할 수 없는 api들이 있음.

 

5. OpenSearch Dashboards 설치

4번에서 생성한 secret을 넣어준다.

helm install opensearch-dashboards opensearch/opensearch-dashboards \
-n logging --create-namespace \
--set-json 'extraEnvs=[{"name": "OPENSEARCH_USERNAME", "valueFrom": {"secretKeyRef": 
{"key": "username", "name": "admin-credentials"}}},
{"name": "OPENSEARCH_PASSWORD", "valueFrom": {"secretKeyRef": 
{"key": "password", "name": "admin-credentials"}}}]'

 

Ingress 설정은 맨위에 OpenSearch FluentBit 연동글을 참고한다.

반응형

'Develop > OpenSearch / FluentBit' 카테고리의 다른 글

OpenSearch metrics Prometheus 연결  (0) 2025.03.23
OpenSearch Dashboards API Console Proxy  (0) 2025.03.13
OpenSearch SingleNode  (0) 2025.03.06
OpenSearch Operator Coordinator  (0) 2025.02.18
Fluent-Bit Systemd Logging  (0) 2025.02.18
반응형

 

OpenSearch Install, OpenSearch Dashboard install 및 Fluent-Bit 연동이다.

OpenSearch 설치시 바로 Helm으로 설치할 경우 패스워드가 없어서 에러가 발생할 뿐만아니라, 데모 인증서가

설치안되는 경우가 있다. 이 경우는 따로 패스워드 설정 및 데모인증서가아닌 인증서를 넣어주면되는데,

마지막에 따로 추가적으로 설정하는 방법을 정리한다.

 

Fluent-Bit 연동은 10번부터, 데모 인증서가 아닌 인증서 설정은 기타부분을 참조한다.

Fluent-Bit 연동을 위해 설치는 아래 링크 참조

2024.11.01 - [Develop/k8s] - k8s fluent-bit install and standard out test

 

0. 로깅 대상 Pod 관련

fluent-bit의 경우 Pod 내 label 이 app: 으로 시작하는 경우 로깅을 하지 못하므로,

반드시 label이 app: 으로 되어있는게 없도록 변경해주어야한다.

 

 

1. 메모리 맵 영역 조정

메모리 맵 영역을 조정하지 않으면 설치 후 에러가 발생함.

모든 서버에 적용.

$ vi /etc/sysctl.conf

# 해당 항목 추가 또는 수정
vm.max_map_count=262144

# 적용
$ sudo sysctl -p

 

 

2. OpenSearch 설치

helm chart로 설치할 예정이므로 아래 사이트에 접속해 helm charts를 다운받는다.

(가이드에 나온대로 바로 helm repo를 추가하여 설치 할 수 있지만, 위에 설명한대로 데모인증서가 설치안되는 경우가 있음.

데모인증서가 설치 안될 경우 아래 기타 항목 참조)

https://github.com/opensearch-project/helm-charts/releases

$ tar -zxvf opensearch-2.26.1.tgz
$ cd opensearch

 

 

3. values.yaml 내 OPENSEARCH_INITIAL_ADMIN_PASSWORD 설정 

ADMIN_PASSWORD를 설정한다. 해당 패스워드 설정하지 않을 경우 설치시 설정하라고 에러 발생

또한, 패스워드를 강하게 설정해야한다. 대문자, 숫자, 특수문자가 들어가야하며, 쉬운패스워드는 또 되지 않는다.

처음에 주석으로 되어있고 extraEnvs: [] 대괄호가 있으므로 대괄호는 반드시 지운다.

$ vi values.yaml
extraEnvs:
  - name: OPENSEARCH_INITIAL_ADMIN_PASSWORD
    value: wkyKr!2024

 

 

4. PV설정

기존 서버에 StorageClass가 설정되어있으면, 패스한다. 

StorageClass 가 없을 경우 PV를 설정해주어야한다. (PVC는 OpenSearch내에 적용되어 있음.)

모든 서버에 볼륨 폴더를 생성한다. (모든 서버에 할 필요는 없으나, 파드가 어디 서버에 동작될지 설정하지 않았으므로,

모든 폴더에 생성한다. 어디에 동작될지 설정할경우 해당 서버에만 폴더를 생성한다.)

 

opensearch가 statefulset으로 기본적으로 pod가 3개정도 동작하므로 pv를 미리 3개정도 만들어둔다.

아니면, helm install 후에 pvc와 pv 이름을 매칭하여 pv를 생성하고 pvc를 수정한다.

편한대로 진행하면됨.

# Worker Node가 2개뿐이라 2개씩 전부 생성
$ mkdir opensearch-pv
$ mkdir opensearch-pv2

 

pv 생성

$ vi pv-0.yaml
apiVersion: v1
metadata:
  name: opensearch-pv-0
  labels:
    service: opensearch-pv-0
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: /root/opensearch-pv
 
$ vi pv-1.yaml
apiVersion: v1
metadata:
  name: opensearch-pv-1
  labels:
    service: opensearch-pv-1
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: /root/opensearch-pv

$ vi pv-2.yaml
apiVersion: v1
metadata:
  name: opensearch-pv-2
  labels:
    service: opensearch-pv-2
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: /root/opensearch-pv2
    
$ kubectl apply -f pv-0.yaml
$ kubectl apply -f pv-1.yaml
$ kubectl apply -f pv-2.yaml

 

 

5. helm install

3번의 values.yaml 수정하였으고 pv를 생성하였으면, 패키징 후 설치한다. (pv는 아래 먼저 실행 후 생성되는 것보고 맞춰서 생성해도 됨)

$ helm package .
$ helm install opensearch opensearch-2.26.1.tgz --create-namespace --namespace logging

# 실행확인
$ kubectl get pods -n logging
NAME                          READY   STATUS    RESTARTS   AGE
opensearch-cluster-master-0   1/1     Running   0          33m
opensearch-cluster-master-1   1/1     Running   0          33m
opensearch-cluster-master-2   1/1     Running   0          33m

 

 

6. 정상동작 확인

$ kubectl exec -it opensearch-cluster-master-0 -n logging -- /bin/bash
$  curl -XGET https://localhost:9200 -u 'admin:wkyKr!2024' --insecure
{
  "name" : "opensearch-cluster-master-0",
  "cluster_name" : "opensearch-cluster",
  "cluster_uuid" : "Iqk-kEIxRNWEvEXkCFX-BQ",
  "version" : {
    "distribution" : "opensearch",
    "number" : "2.17.1",
    "build_type" : "tar",
    "build_hash" : "1893d20797e30110e5877170e44d42275ce5951e",
    "build_date" : "2024-09-26T21:59:52.691008096Z",
    "build_snapshot" : false,
    "lucene_version" : "9.11.1",
    "minimum_wire_compatibility_version" : "7.10.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "The OpenSearch Project: https://opensearch.org/"
}

 

 

7. OpenSearch DashBoard 설치

OpenSeach와 마찬가지로 helm chart로 설치할 예정이므로 아래 사이트에 접속해 helm charts를 다운받는다.

https://github.com/opensearch-project/helm-charts/releases

 

다운 받았으면, 바로 실행한다.

$ helm install opensearch-dashboards opensearch-dashboards-2.24.1.tgz --create-namespace --namespace logging

# 실행 후 확인
$ kubectl get pods -n logging
NAME                                     READY   STATUS    RESTARTS   AGE
opensearch-dashboards-649d556895-r4vwn   1/1     Running   0          2m13s

 

 

8. OpenSearch DashBoard 접근을 위한 ingress 설정

$ vi ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: opensearch-dashboard
  namespace: logging
spec:
  ingressClassName: nginx
  rules:
  - host: os-dashboard.wky.kr
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: opensearch-dashboards
            port:
              number: 5601
              
 $ kubectl apply -f ingress.yaml

 

 

9. 접속 확인

계정은 admin

패스워드는 3번에 설정한 패스워드 입력

 

 

10. Fluent-Bit 연동

먼저 Fluent-Bit 이 설치되어 있어야 한다. 설치방법은 아래 링크 참조

2024.11.01 - [Develop/k8s] - k8s fluent-bit install and standard out test

(위 링크에 따라 그대로 설정했으면 stdout 부분은 제거한다.)

OUTPUT 옵션은 필요에 따라 가이드보고 적용하며,

Host는 oepnsearch가 statefulset으로 동작하므로 opensearch service의 headless service로 연결한다.

$ kubectl edit cm fluent-bit
# [OUTPUT] 에 stdout이 있으면 해당 부분 제거 후 아래 부분 추가

   [OUTPUT]
        Name opensearch
        Match kube.*
        Host opensearch-cluster-master-headless.logging
        Port 9200
        tls On
        tls.verify Off
        HTTP_User admin
        HTTP_Passwd wkyKr!2024
        Retry_Limit False
        Suppress_Type_Name On

 

fluent-bit 의 config map hot reload 를 설정하지 않았으므로, fluent-bit pod를 전체 재기동한다.

 

11. 연동 후 OpenSearch에서 확인을 위해 서비스를 통한 로깅 테스트 후 Fluent-Bit 확인

2024.11.01 - [Develop/k8s] - k8s fluent-bit install and standard out test

해당 글에서 생성한 서비스의 로그가 잘 표시되는 것을 확인

 

 

기타. 데모인증서가 아닌 인증서 설정

helm 내의 values.yaml 를 수정하지 않고 바로 공식 가이드 대로 배포할 경우 패스워드도 없고 데모 인증서가 생성 되지 않을 경우가 있는데,

패스워드를 설정하고 인증서 생성 후 인증서는 pv에 넣어주면 된다.

 

1. 패스워드 설정

패스워드 설정은 statefulset의 환경변수에 입력해주면된다.

$ kubectl edit sts -n logging opensearch-cluster-master
...
containers:
      - env:
        - name: OPENSEARCH_INITIAL_ADMIN_PASSWORD
          value: wkyKr!2024
...

 

 

2. PV는 있다고 가정 후 인증서 생성 (없을 경우 위 내용 중 4번 확인)

$ openssl genrsa -out root-ca-key.pem 2048
$ openssl req -new -x509 -sha256 -key root-ca-key.pem -out root-ca.pem -days 730
$ openssl genrsa -out esnode-key-temp.pem 2048
$ openssl pkcs8 -inform PEM -outform PEM -in esnode-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out esnode-key.pem
$ openssl req -new -key esnode-key.pem -out esnode.csr
$ openssl x509 -req -in esnode.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out esnode.pem -days 730

 

 

3. 생성한 인증서 중 esnode.pem, esnode-key.pem, root-ca.pem 을 pv 폴더에 이동

OpenSearch pod 와 pv 간 mountPath가 안맞는 경우가 있어 statefulset 내 mountPath수정함.

또한 위 4번에서 생성한 opensearch-pv, opensearch-pv2 폴더내 config 폴더 생성

esnode.pem, esnode-key.pem, root-ca.pem 를 config 폴더에 이동

$ kubectl get sts -n logging opensearch-cluster-master -o yaml

# 수정 전
- mountPath: /usr/share/opensearch/config/opensearch.yml
  name: config-emptydir
  
# 수정 후
- mountPath: /usr/share/opensearch/data/config/opensearch.yml
  name: config-emptydir
  
$ mkdir ~/opensearch-pv/config
$ mkdir ~/opensearch-pv2/config

esnode.pem, esnode-key.pem, root-ca.pem 해당폴더로 복사한다

 

4. config map 수정

  allow_unsafe_democertificates: true -> false로 수정

$ kubectl edit cm -n logging opensearch-cluster-master-config -o yaml

# 기존에 true로 되어있음 false로 수정
allow_unsafe_democertificates: false

 

 

참고 :

https://opensearch.org/docs/latest/install-and-configure/install-opensearch/index/

https://opensearch.org/docs/latest/install-and-configure/install-opensearch/helm/

https://opensearch.org/docs/latest/install-and-configure/install-dashboards/helm/

https://opensearch.org/docs/latest/security/configuration/generate-certificates/

https://docs.fluentbit.io/manual/pipeline/outputs/opensearch

 

반응형

+ Recent posts