云服务器内容精选

  • 常见问题 如果kubectl没有配置成功,helm install时会出现如下报错。 # helm install prometheus/ --generate-name WARNING: This chart is deprecated Error: Kubernetes cluster unreachable: Get "http://localhost:8080/version?timeout=32s": dial tcp [::1]:8080: connect: connection refused 解决办法:给节点配置kubeconfig,配置方法请参见使用kubectl连接集群。
  • 前提条件 确保接入的节点与 APM 服务网络连通。可使用Telnet命令测试目标机器与APM服务器网络是否连通。 例如,以检查华北-北京四区域,且代码源选择“增强型探针”的连通性为例,请登录应用所部署的机器,并输入命令telnet 100.125.12.108:41333,其他区域地址请参考表1。 表1 增强型探针接入地址 区域 接入地址 华北-北京四 https://100.125.12.108:41333 华北-北京一 https://100.125.57.101:41333 华东-上海一 https://100.125.4.27:41333 华东-上海二 https://100.125.140.105:41333 华南-广州 https://100.125.143.102:41333 亚太-新加坡 https://100.125.4.25:41333 华南-广州-友好用户环境 https://100.125.4.30:41333 华北-乌兰察布一 https://100.125.4.30:41333 华北-乌兰察布二零一 https://100.79.6.100:41333 华北-乌兰察布二零二 https://100.79.6.100:41333 华北-乌兰察布汽车一 https://100.125.254.17:41333 西南-贵阳一 https://100.125.0.90:41333 中国-香港 https://100.125.6.106:41333 请确保您的Kubernetes集群版本为1.19及以上。 进程所需最大堆内存250 MB,最大CPU使用0.25 Core。
  • 配置示例 spec: replicas: 1 selector: matchLabels: app: vmall-admin version: v1 template: metadata: creationTimestamp: null labels: app: vmall-admin version: v1 spec: volumes: - name: vol-171526714525730640 hostPath: path: /vmall/vmall-deploy/vmall-data/app/vmall-admin/logs type: '' - name: paas-apm2 emptyDir: {} initContainers: - name: init-javaagent image: swr.cn-north-4.myhuaweicloud.com/op_svc_apm/javaagent:2.4.8-x86_64 command: - /bin/sh - '-c' - cd /paas-apm2/javaagent/apm-javaagent; /bin/sh init-config.sh -master_address https://100.125.12.108:41333 -app_name vmall-admin -access_key {AK} -access_value {SK} -business vmall-demo resources: limits: cpu: 250m memory: 250Mi requests: cpu: 250m memory: 250Mi volumeMounts: - name: paas-apm2 mountPath: /var/init/javaagent terminationMessagePath: /dev/termination-log terminationMessagePolicy: File imagePullPolicy: Always monitorGroup: default containers: - name: vmall-admin image: swr.cn-north-4.myhuaweicloud.com/vmall-org/vmall-admin:1.0.0 env: - name: PAAS_APP_NAME value: vmall-admin - name: PAAS_NAMESPACE value: default - name: PAAS_PROJECT_ID value: e49731583bc54978aa7b4da1a2196e46 - name: CLOUDDEPLOY_SYS_INCREMENT value: '1719279081896' - name: JAVA_TOOL_OPTIONS value: '-javaagent:/paas-apm2/javaagent/apm-javaagent/apm-javaagent.jar' resources: limits: cpu: '1' memory: 2Gi requests: cpu: 500m memory: 1Gi volumeMounts: - name: vol-171526714525730640 mountPath: /var/logs - name: paas-apm2 mountPath: /paas-apm2/javaagent/ terminationMessagePath: /dev/termination-log terminationMessagePolicy: File imagePullPolicy: Always restartPolicy: Always terminationGracePeriodSeconds: 30 dnsPolicy: ClusterFirst securityContext: {} imagePullSecrets: - name: default-secret schedulerName: default-scheduler tolerations: - key: node.kubernetes.io/not-ready operator: Exists effect: NoExecute tolerationSeconds: 300 - key: node.kubernetes.io/unreachable operator: Exists effect: NoExecute tolerationSeconds: 300
  • 操作步骤 编辑deployment.yaml。 在volumes中增加一个emptyDir。 volumes: - name: paas-apm2 emptyDir: {} 在containers.volumeMounts中增加moutPath。 volumeMounts: - name: paas-apm2 mountPath: /paas-apm2/javaagent/ 在env中增加JAVA_TOOL_OPTIONS环境变量。 env: - name: JAVA_TOOL_OPTIONS value: '-javaagent:/paas-apm2/javaagent/apm-javaagent/apm-javaagent.jar' 新增initContainers。 initContainers: - name: init-javaagent image: {swrAddress}/op_svc_apm/javaagent:{agentVersion} command: - /bin/sh - '-c' - cd /paas-apm2/javaagent/apm-javaagent; /bin/sh init-config.sh -master_address {masterAddress} -app_name {appName} -access_key {accessKey} -access_value {secretKey} -business {business} -env {env} resources: limits: cpu: 250m memory: 250Mi requests: cpu: 250m memory: 250Mi volumeMounts: - name: paas-apm2 mountPath: /var/init/javaagent terminationMessagePath: /dev/termination-log terminationMessagePolicy: File imagePullPolicy: Always monitorGroup: default