Izek Chen
3 min readMar 1, 2020

--

command: kubectl get crd -n elasticsearch
NAME CREATED AT
apmservers.apm.k8s.elastic.co 2020-02-18T03:47:42Z
elasticsearches.elasticsearch.k8s.elastic.co 2020-02-18T03:47:42Z
eniconfigs.crd.k8s.amazonaws.com 2019-12-24T12:55:36Z
kibanas.kibana.k8s.elastic.co 2020-02-18T03:47:42Z
### elastic-apm.yaml
apiVersion: apm.k8s.elastic.co/v1
kind: ApmServer
metadata:
name: elastic-apm
namespace: elasticsearch
spec:
version: 7.6.0
count: 1
hostNetwork: true
http:
tls: ### for make it easy to test, let's disable tls for now
selfSignedCertificate:
disabled: true
config:
name: elastic-apm
apm-server:
jaeger.grpc.enabled: true
jaeger.http.enabled: true
rum.enabled: true
rum.event_rate.limit: 300
rum.event_rate.lru_size: 1000
rum.allow_origins: ['']
rum.library_pattern: "node_modules|bower_components|~"
rum.exclude_from_grouping: "^/webpack"
rum.source_mapping.enabled: true
rum.source_mapping.cache.expiration: 5m
rum.source_mapping.index_pattern: "apm--sourcemap*"
elasticsearchRef:
name: "elastic-operator"
kubectl apply -f ./elastic-apm.yaml
apmserver.apm.k8s.elastic.co/elastic-apm created
kubectl get apmservers -n elasticsearch
NAME HEALTH NODES VERSION AGE
elastic-apm green 1 7.6.0 176m
###sample-application.yaml
### kubectl apply -f sample-application.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: petclinic
namespace: elasticsearch
labels:
app: petclinic
service: petclinic
spec:
replicas: 1
selector:
matchLabels:
app: petclinic
template:
metadata:
labels:
app: petclinic
service: petclinic
spec:
dnsPolicy: ClusterFirstWithHostNet
###################### Shared volume and init container ##########################
volumes:
- name: elastic-apm-agent
emptyDir: {}
initContainers:
- name: elastic-java-agent
image: docker.elastic.co/observability/apm-agent-java:1.12.0
volumeMounts:
- mountPath: /elastic/apm/agent
name: elastic-apm-agent
command: ['cp', '-v', '/usr/agent/elastic-apm-agent.jar', '/elastic/apm/agent']
##################################################################################
containers:
- name: petclinic
image: eyalkoren/pet-clinic:without-agent
######################### Volume path and agent config ###########################
volumeMounts:
- mountPath: /elastic/apm/agent
name: elastic-apm-agent
env:
- name: ELASTIC_APM_SERVER_URL
value: "http://elastic-apm-apm-http.elasticsearch.svc.cluster.local:8200"
- name: ELASTIC_APM_SERVICE_NAME
value: "petclinic"
- name: ELASTIC_APM_APPLICATION_PACKAGES
value: "org.springframework.samples.petclinic"
- name: ELASTIC_APM_ENVIRONMENT
value: test
- name: ELASTIC_APM_LOG_LEVEL
value: DEBUG
- name: ELASTIC_APM_SECRET_TOKEN
valueFrom:
secretKeyRef:
name: elastic-apm-apm-token
key: secret-token
- name: JAVA_TOOL_OPTIONS
value: -javaagent:/elastic/apm/agent/elastic-apm-agent.jar
---
apiVersion: v1
kind: Service
metadata:
name: petclinic
namespace: elasticsearch
labels:
app: petclinic
spec:
type: NodePort
ports:
- protocol: TCP
port: 8080
targetPort: 8080
nodePort: 30001
selector:
service: petclinic
kubectl port-forward svc/petclinic -n elasticsearch 8080:8080
Front page
Error test
APM view

--

--