# How to install elastic search fleet server on Kubernetes

**URL:** https://discuss.elastic.co/t/how-to-install-elastic-search-fleet-server-on-kubernetes/326880
**Category:** Elastic Agent
**Tags:** fleet
**Created:** [March 2, 2023, 6:03pm UTC](https://discuss.elastic.co/t/how-to-install-elastic-search-fleet-server-on-kubernetes/326880 "2023-03-02T18:03:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![iojas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iojas/32/117987_2.png) [@iojas](https://discuss.elastic.co/u/iojas)
#### Post date: [March 2, 2023, 6:03pm UTC](https://discuss.elastic.co/t/how-to-install-elastic-search-fleet-server-on-kubernetes/326880/1 "2023-03-02T18:03:56Z")

</div>

I think I have been going round and round with the whole setup. I am able to get the fleet connection working when working with ECK on cloud. Since it's a managed instance it comes prebuilt with fleet server installed. while installing agents on my OTHER Kubernetes cluster I can just use the fleet URL provided by managed ECK. my configuration looks like this.

```auto
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: elastic-agent
  namespace: kube-system
.
.
.
- name: FLEET_URL
  value: "https://XXXX.fleet.eastus.azure.elastic-cloud.com:443"
- name: FLEET_ENROLLMENT_TOKEN
  value: "XXX=="

```

correct me if I am wrong this is the fleet server that is installed on managed elastic cloud.

This works perfectly fine I can see data flowing from my prod cluster to this managed ECK cluster.

Now I want to setup fleet server on my monitoring cluster and hoping to see data going from one cluster to this monitoring cluster, just like what I did with managed ECK.

This is the agent server definition I have

```auto
apiVersion: agent.k8s.elastic.co/v1alpha1
kind: Agent
metadata:
  name: fleet-server
spec:
  version: 8.6.2
  kibanaRef:
    name: kibana
  elasticsearchRefs:
  - name: elastic
  mode: fleet
  fleetServerEnabled: true
  deployment:
    replicas: 1
    podTemplate:
      spec:
        serviceAccountName: fleet-server
        automountServiceAccountToken: true
        securityContext:
          runAsUser: 0

```

I can see fleet-server pod running, also see `Fleet Server Hosts` populated as `https://fleet-server-agent-http.default.svc:8220` in Kibana. Based on this I should be able to add Fleet Server in kibana. When I follow the directions to add fleet server in kibana finally I end up with command which looks something like this.

```auto
curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-8.6.2-linux-x86_64.tar.gz
tar xzvf elastic-agent-8.6.2-linux-x86_64.tar.gz
cd elastic-agent-8.6.2-linux-x86_64
sudo ./elastic-agent install \
  --fleet-server-es=https://ES_INGRESS:443 \
  --fleet-server-service-token=XXX \
  --fleet-server-policy=fleet-server-policy

```

I am not sure where are we suppose to run this command in Kubernetes.

I was expecting something like a YAML which can setup agent-server for me on this self managed monitoring cluster.

what am I missing here.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [March 30, 2023, 6:04pm UTC](https://discuss.elastic.co/t/how-to-install-elastic-search-fleet-server-on-kubernetes/326880/2 "2023-03-30T18:04:16Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
