본문 바로가기

etc

k8s stable agent

apiVersion: "v1"
kind: "Namespace"
metadata:
  name: "whatap-monitoring"
---
apiVersion: "v1"
kind: "ServiceAccount"
metadata:
  name: "whatap"
  namespace: "whatap-monitoring"
---
apiVersion: "rbac.authorization.k8s.io/v1"
kind: "ClusterRole"
metadata:
  annotations:
    rbac.authorization.kubernetes.io/autoupdate: "true"
  name: "whatap"
  namespace: "whatap-monitoring"
rules:
- apiGroups:
  - "*"
  resources:
  - "namespaces"
  - "pods"
  - "pods/log"
  - "configmaps"
  - "services"
  - "endpoints"
  - "daemonsets"
  - "ingresses"
  - "deployments"
  - "nodes"
  - "persistentvolumes"
  - "persistentvolumeclaims"
  - "events"
  - "replicasets"
  - "roles"
  - "rolebindings"
  - "clusterroles"
  - "clusterrolebindings"
  - "jobs"
  - "cronjobs"
  - "statefulsets"
  - "serviceaccounts"
  - "configmaps"
  - "storageclasses"
  - "horizontalpodautoscalers"
  - "replicationcontrollers"
  verbs:
  - "get"
  - "list"
  - "watch"
- apiGroups:
  - ""
  resources:
  - "pods/exec"
  verbs:
  - "create"
- apiGroups:
  - ""
  resources:
  - "configmaps"
  verbs:
  - "*"
- nonResourceURLs:
  - "/metrics"
  verbs:
  - "*"
---
apiVersion: "rbac.authorization.k8s.io/v1"
kind: "ClusterRoleBinding"
metadata:
  name: "whatap"
roleRef:
  apiGroup: "rbac.authorization.k8s.io"
  kind: "ClusterRole"
  name: "whatap"
subjects:
- kind: "ServiceAccount"
  name: "whatap"
  namespace: "whatap-monitoring"
---
apiVersion: "v1"
data:
  entrypoint.sh: |-
    #!/usr/bin/env bash

    mkdir /whatap_conf/confbase -p
    if [ ! -f /whatap_conf/confbase/whatap_server.conf ]; then
    cat >/whatap_conf/confbase/whatap_server.conf <<EOL
    license=$WHATAP_LICENSE
    whatap.server.host=$WHATAP_HOST
    whatap.server.port=$WHATAP_PORT
    EOL
    fi

    if [ ! -f /whatap_conf/whatap.master.conf ]; then
    cat >/whatap_conf/whatap.master.conf <<EOL
    master_agent_port=6600
    license=$WHATAP_LICENSE
    whatap.server.host=$WHATAP_HOST
    whatap.server.port=$WHATAP_PORT
    confbase_backup_enabled=true
    EOL
    fi

    heapsize=$(echo "0.45 $WHATP_MEM_LIMIT" | awk '{print int($1 * $2 / 1048576)}')
    JAVA_OPTS="-Xms${heapsize}m -Xmx${heapsize}m"
    JAVA_OPTS="$JAVA_OPTS -XX:+UseG1GC -XX:+UseStringDeduplication  -XX:+ExitOnOutOfMemoryError -XshowSettings:vm"
    JAVA_OPTS="$JAVA_OPTS -Dwhatap.home=/whatap_conf"

    java $JAVA_OPTS -cp /data/agent/confbase/whatap.agent.confbase-1.0.0.jar:/data/agent/master/whatap.kube.master-1.0.1.jar whatap.agent.App
kind: "ConfigMap"
metadata:
  name: "master-start-script"
  namespace: "whatap-monitoring"
---
apiVersion: "v1"
data:
  entrypoint.sh: |-
    #!/usr/bin/env bash

    cat >/whatap_conf/whatap.node.conf <<EOL
    license=$WHATAP_LICENSE
    whatap.server.host=$WHATAP_HOST
    whatap.server.port=$WHATAP_PORT
    imageignore=k8s.gcr.io/pause:3.1,docker.io/openshift/origin-pod:v3.11.0
    commandignore=/pause,/usr/bin/pod
    whatap.name=$NODE_NAME
    helper_embedded=false
    EOL

    heapsize=$(echo "0.45 $WHATP_MEM_LIMIT" | awk '{print int($1 * $2 / 1048576)}')
    JAVA_OPTS="-Xms${heapsize}m -Xmx${heapsize}m"
    JAVA_OPTS="$JAVA_OPTS -XX:+UseG1GC -XX:+UseStringDeduplication  -XX:+ExitOnOutOfMemoryError -XshowSettings:vm"
    JAVA_OPTS="$JAVA_OPTS -Dwhatap.home=/whatap_conf"

    java $JAVA_OPTS -jar /data/agent/node/whatap.kube.node-*.jar
kind: "ConfigMap"
metadata:
  name: "node-start-script"
  namespace: "whatap-monitoring"
---
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
  name: "whatap-master-agent"
  namespace: "whatap-monitoring"
spec:
  replicas: 1
  selector:
    matchLabels:
      name: "whatap-master-agent"
  template:
    metadata:
      labels:
        name: "whatap-master-agent"
    spec:
      containers:
      - command:
        - "/bin/entrypoint.sh"
        env:
        - name: "WHATAP_LICENSE"
          value: "x6058gs835of4-z5epiu41hl3ta2-x39mkudp906ivp"
        - name: "WHATAP_HOST"
          value: "210.109.61.195/210.109.61.164"
        - name: "WHATAP_PORT"
          value: "6600"
        - name: "WHATP_MEM_LIMIT"
          valueFrom:
            resourceFieldRef:
              containerName: "whatap-master-agent"
              resource: "limits.memory"
        - name: "collect_control_plane_monitoring_enabled"
          value: "true"
        image: "whatap/kube_mon:1.7.10"
        name: "whatap-master-agent"
        ports:
        - containerPort: 6600
        resources:
          limits:
            cpu: "200m"
            memory: "350Mi"
          requests:
            cpu: "100m"
            memory: "300Mi"
        volumeMounts:
        - mountPath: "/bin/entrypoint.sh"
          name: "start-script-volume"
          readOnly: true
          subPath: "entrypoint.sh"
        - mountPath: "/whatap_conf"
          name: "whatap-config-volume"
      - args:
        - "-collect_control_plane_monitoring_enabled=true"
        command:
        - "/data/agent/master/whatap_control_plane_helper"
        image: "whatap/kube_mon:1.7.10"
        imagePullPolicy: "Always"
        name: "whatap-control-plane-helper"
        ports:
        - containerPort: 9496
      serviceAccount: "whatap"
      volumes:
      - configMap:
          defaultMode: 448
          name: "master-start-script"
        name: "start-script-volume"
      - emptyDir: {}
        name: "whatap-config-volume"
---
apiVersion: "apps/v1"
kind: "DaemonSet"
metadata:
  labels:
    name: "whatap-node-agent"
  name: "whatap-node-agent"
  namespace: "whatap-monitoring"
spec:
  selector:
    matchLabels:
      name: "whatap-node-agent"
  template:
    metadata:
      labels:
        name: "whatap-node-agent"
    spec:
      containers:
      - command:
        - "/data/agent/node/cadvisor_helper"
        - "-port"
        - "6801"
        env:
        - name: "NODE_NAME"
          valueFrom:
            fieldRef:
              fieldPath: "spec.nodeName"
        image: "whatap/kube_mon:1.7.10"
        name: "whatap-node-helper"
        ports:
        - containerPort: 6801
          name: "helperport"
        resources:
          limits:
            cpu: "200m"
            memory: "350Mi"
          requests:
            cpu: "100m"
            memory: "100Mi"
        volumeMounts:
        - mountPath: "/rootfs"
          name: "rootfs"
          readOnly: true
        - mountPath: "/sys"
          name: "hostsys"
          readOnly: true
        - mountPath: "/dev/disk"
          name: "hostdiskdevice"
          readOnly: true
        - mountPath: "/run/containerd/containerd.sock"
          name: "containerddomainsocket"
      - command:
        - "/bin/entrypoint.sh"
        env:
        - name: "NODE_IP"
          valueFrom:
            fieldRef:
              fieldPath: "status.hostIP"
        - name: "NODE_NAME"
          valueFrom:
            fieldRef:
              fieldPath: "spec.nodeName"
        - name: "WHATAP_LICENSE"
          value: "x6058gs835of4-z5epiu41hl3ta2-x39mkudp906ivp"
        - name: "WHATAP_HOST"
          value: "210.109.61.195/210.109.61.164"
        - name: "WHATAP_PORT"
          value: "6600"
        - name: "HOST_PREFIX"
          value: "/rootfs"
        - name: "WHATP_MEM_LIMIT"
          valueFrom:
            resourceFieldRef:
              containerName: "whatap-node-agent"
              resource: "limits.memory"
        image: "whatap/kube_mon:1.7.10"
        name: "whatap-node-agent"
        ports:
        - containerPort: 6600
          name: "nodeport"
        resources:
          limits:
            cpu: "200m"
            memory: "350Mi"
          requests:
            cpu: "100m"
            memory: "300Mi"
        volumeMounts:
        - mountPath: "/rootfs"
          name: "rootfs"
          readOnly: true
        - mountPath: "/bin/entrypoint.sh"
          name: "start-script-volume"
          readOnly: true
          subPath: "entrypoint.sh"
        - mountPath: "/whatap_conf"
          name: "whatap-config-volume"
      initContainers:
      - command:
        - "/data/agent/tools/whatap_debugger"
        - "run"
        image: "whatap/kube_mon:1.7.10"
        name: "whatap-node-debug"
        volumeMounts:
        - mountPath: "/rootfs"
          name: "rootfs"
          readOnly: true
      serviceAccount: "whatap"
      tolerations:
      - effect: "NoSchedule"
        key: "node-role.kubernetes.io/master"
      - effect: "NoSchedule"
        key: "node-role.kubernetes.io/control-plane"
      volumes:
      - hostPath:
          path: "/"
        name: "rootfs"
      - hostPath:
          path: "/sys"
        name: "hostsys"
      - hostPath:
          path: "/dev/disk"
        name: "hostdiskdevice"
      - configMap:
          defaultMode: 448
          name: "node-start-script"
        name: "start-script-volume"
      - emptyDir: {}
        name: "whatap-config-volume"
      - hostPath:
          path: "/run/containerd/containerd.sock"
        name: "containerddomainsocket"
---
apiVersion: "v1"
kind: "Service"
metadata:
  labels:
    run: "whatap-master-agent"
  name: "whatap-master-agent"
  namespace: "whatap-monitoring"
spec:
  clusterIP: "None"
  ports:
  - name: "tcp-whatap-master-agent"
    port: 6600
    protocol: "TCP"
  - name: "tcp-whatap-confbase"
    port: 6800
    protocol: "TCP"
  selector:
    name: "whatap-master-agent"

'etc' 카테고리의 다른 글

Powershell Firewall Control  (0) 2024.03.15
인텔리제이 typo in word 없애기  (0) 2021.12.02