목차

개요

사전조건

Git Clone

sansae@workspace-win10:/mnt/c/apps/myworks$ git clone https://github.com/Sanses/pinpoint-kubernetes.git
Cloning into 'pinpoint-kubernetes'...
remote: Enumerating objects: 145, done.
remote: Counting objects: 100% (145/145), done.
remote: Compressing objects: 100% (93/93), done.
remote: Total 145 (delta 76), reused 99 (delta 44), pack-reused 0
Receiving objects: 100% (145/145), 28.00 KiB | 1.87 MiB/s, done.
Resolving deltas: 100% (76/76), done.
sansae@workspace-win10:/mnt/c/apps/myworks$
sansae@workspace-win10:/mnt/c/apps/myworks$ cd pinpoint-kubernetes/
sansae@workspace-win10:/mnt/c/apps/myworks/pinpoint-kubernetes$ ls -al
total 12
drwxrwxrwx 1 sansae sansae  4096 Oct 14 13:33 .
drwxrwxrwx 1 sansae sansae  4096 Oct 14 13:33 ..
drwxrwxrwx 1 sansae sansae  4096 Oct 14 13:33 .git
-rwxrwxrwx 1 sansae sansae   169 Oct 14 13:33 .gitignore
-rwxrwxrwx 1 sansae sansae 11358 Oct 14 13:33 LICENSE
-rwxrwxrwx 1 sansae sansae    59 Oct 14 13:33 README.md
drwxrwxrwx 1 sansae sansae  4096 Oct 14 13:33 pinpoint

Add Repository for Dependency

$ helm repo add gradiant https://gradiant.github.io/charts
$ helm repo add incubator https://charts.helm.sh/incubator 
$ helm repo add stable https://charts.helm.sh/stable

Deploy Pinpoint

$ helm dependency update .
$ kubectl create ns [Namespace]
$ helm install [Release Name] . -n [Namespace]

Uninstall Pinpoint

$ helm uninstall [Release Name] -n [Namespace]
$ kubectl delete ns [Namespace]

Guide for Dockerfile & k8s manifests

Dockerfile

FROM openjdk:11-jre-slim

RUN groupadd appgroup && useradd -G appgroup appuser
WORKDIR /app
RUN chown appuser:appgroup /app
USER appuser

ENV TZ=Asia/Seoul
EXPOSE 8080

COPY target/*.jar /app/app.jar

COPY pinpoint/pinpoint-agent-2.2.2.tar.gz /app/pinpoint-agent-2.2.2.tar.gz
RUN mkdir /app/pinpoint-agent \
    && tar -xf /app/pinpoint-agent-2.2.2.tar.gz --strip 1 -C /app/pinpoint-agent \
    && rm /app/pinpoint-agent-2.2.2.tar.gz \
    && chmod 777 /app/pinpoint-agent/logs
COPY pinpoint/pinpoint.config /app/pinpoint-agent/pinpoint.config

COPY shell/invoke.sh /app/invoke.sh

ENTRYPOINT /bin/bash /app/invoke.sh

Configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: pinpoint-config
data:

  APPLICATION_NAME: micro-app
  JAVA_OPTS: "-server -Xmx2g -Xms2g -Dspring.profiles.active=prod"
  PINPOINT_OPTS: "-javaagent:/app/pinpoint-agent/pinpoint-bootstrap-2.2.2.jar -Dpinpoint.config=/app/pinpoint-agent/pinpoint.config"

Deployment.yaml

apiVersion : apps/v1
kind: Deployment
metadata:
  name: micro-app
spec:
      containers:
        - name: micro-app
          image: {ContainerRegistry}/apps/micro-app
          env:
            - name: MY_POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name

          envFrom:
          - configMapRef:
              name: pinpoint-config

invoke.sh

#!/bin/bash
if [[ -n "${PINPOINT_OPTS}" ]]; then
  exec java ${JAVA_OPTS} ${PINPOINT_OPTS} -Dpinpoint.applicationName=${APPLICATION_NAME} -Dpinpoint.agentId="${APPLICATION_NAME}-${MY_POD_NAME:(-5)}" -jar /app/app.jar
else
  exec java ${JAVA_OPTS} -jar /app/app.jar

  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.