Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info
title목차

Table of Contents

개요

Info

사전조건

Info

Git Clone

Code Block
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

Info

> $ 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

Info

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

Uninstall Pinpoint

Info

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

Guide for Dockerfile & k8s manifests

Info
iconfalse
titleDockerfile

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

Info
iconfalse
titleConfigmap.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"

Info
iconfalse
titleDeployment.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

Info
iconfalse
titleinvoke.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