Movatterモバイル変換


[0]ホーム

URL:


Loading
  1. Elastic Docs/
  2. Deploy and manage/
  3. Deploy/
  4. Elastic Cloud on Kubernetes/
  5. Manage deployments

Deploy an Elasticsearch cluster

To deploy a simpleElasticsearch cluster specification, with one Elasticsearch node:

cat <<EOF | kubectl apply -f -apiVersion: elasticsearch.k8s.elastic.co/v1kind: Elasticsearchmetadata:  name: quickstartspec:  version: 9.3.0  nodeSets:  - name: default    count: 1    config:      node.store.allow_mmap: falseEOF

The operator automatically creates and manages Kubernetes resources to achieve the desired state of the Elasticsearch cluster. It may take up to a few minutes until all the resources are created and the cluster is ready for use.

Warning

Settingnode.store.allow_mmap: false has performance implications and should be tuned for production workloads as described in theVirtual memory section.

Note

If your Kubernetes cluster does not have any Kubernetes nodes with at least 2GiB of free memory, the pod will be stuck inPending state. CheckManage compute resources for more information about resource requirements and how to configure them.

Note

The cluster that you deployed in this quickstart guide only allocates a persistent volume of 1GiB for storage using the defaultstorage class defined for the Kubernetes cluster. You will most likely want to have more control over this for production workloads. Refer toVolume claim templates for more information.

For a full description of eachCustomResourceDefinition (CRD), refer to theAPI Reference or view the CRD files in theproject repository. You can also retrieve information about a CRD from the cluster. For example, describe the Elasticsearch CRD specification withdescribe:

kubectl describe crd elasticsearch

Get an overview of the current Elasticsearch clusters in the Kubernetes cluster withget, including health, version and number of nodes:

kubectl get elasticsearch

When you first create the Kubernetes cluster, there is noHEALTH status and thePHASE is empty. After the pod and service start-up, thePHASE turns intoReady, andHEALTH becomesgreen. TheHEALTH status comes from Elasticsearch'scluster health API.

NAME          HEALTH    NODES     VERSION   PHASE         AGEquickstart              1         9.3.0               1s

While the Elasticsearch pod is in the process of being started it will reportPending as checked withget:

kubectl get pods --selector='elasticsearch.k8s.elastic.co/cluster-name=quickstart'

Which will output similar to:

NAME                      READY   STATUS    RESTARTS   AGEquickstart-es-default-0   0/1     Pending   0          9s

During and after start-up, up that pod’slogs can be accessed:

kubectl logs -f quickstart-es-default-0

Once the pod has finished coming up, our originalget request will now report:

NAME          HEALTH    NODES     VERSION   PHASE         AGEquickstart    green     1         9.3.0     Ready         1m

AClusterIP Service is automatically created for your cluster as checked withget:

kubectl get service quickstart-es-http

Which will output similar to:

NAME                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGEquickstart-es-http   ClusterIP   10.15.251.145   <none>        9200/TCP   34m

In order to make requests to theElasticsearch API:

  1. Get the credentials.

    By default, a user namedelastic is created with the password stored inside aKubernetes secret. This default user can be disabled if desired, refer toUsers and roles for more information.

    PASSWORD=$(kubectl get secret quickstart-es-elastic-user -o go-template='{{.data.elastic | base64decode}}')
  2. Request theElasticsearch root API. You can do so from inside the Kubernetes cluster or from your local workstation. For demonstration purposes, certificate verification is disabled using the-k curl flag; however, this is not recommended outside of testing purposes. Refer toSetup your own certificate for more information.

    • From inside the Kubernetes cluster:

      curl -u "elastic:$PASSWORD" -k "<ELASTICSEARCH_HOST_URL>:9200"
    • From your local workstation:

      1. Use the following command in a separate terminal:

        kubectl port-forward service/quickstart-es-http 9200
      2. Requestlocalhost:

        curl -u "elastic:$PASSWORD" -k "https://localhost:9200"

This completes the quickstart of deploying an Elasticsearch cluster. We recommend continuing to:


[8]ページ先頭

©2009-2026 Movatter.jp