Skip to content

Add annotations to inject resource limitations to the init container #8258

@zypln

Description

@zypln

Search before asking

  • I had searched in the issues and found no similar issues.

Apache SkyWalking Component

SWCK (apache/skywalking-swck)

What happened

Environment:

k8s version: 1.14.8
SWCK version: 0.4.0

Background:

Our k8s cluster is shared by several users and teams.Different teams work in different namespaces.In order to limit the total amount of compute resources per namespace, the resourcequota is set as following example:

kubectl -n systest get resourcequota resourcequota -o yaml
---
apiVersion: v1
kind: ResourceQuota
metadata:
  name: resourcequota
  namespace: systest
spec:
  hard:
    limits.cpu: "32"
    limits.memory: 128Gi
    requests.cpu: "8"
    requests.memory: 32Gi
---

Question:
Based on the above background, when we deploy the java application using skywalking swck: v0.4.0 to inject initContainer, Pod can not be created and the following issue is encounterd "pods xxx is forbidden: failed quota: resourcequota: must specify limits.cpu,limits.memory,requests.cpu,requests.memory'".Therefore, my question is how to set the resources parameter when injecting initcontainer with skywalking swck: v0.4.0 when the namespace has set resourcequota.

If we remove the resourcequota from the namespace, SWCK injection can work normally.

Additional information

The deployment yaml is as follows:

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: javatest-gc
  namespace: systest
spec:
  replicas: 1
  selector:
    matchLabels:
      app: javatest-gc
  template:
    metadata:
      labels:
        swck-java-agent-injected: "true"
        app: javatest-gc
      annotations:
        sidecar.skywalking.apache.org/initcontainer.Image: "artifactory.dev.cmbc.cn:31345/dockerpf-docker-prd-local/skywalking-java-agent:8.5.0"
        sidecar.skywalking.apache.org/env.Name: "JAVA_TOOL_OPTIONS"
        sidecar.skywalking.apache.org/env.Value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
        strategy.skywalking.apache.org/agent.Overlay: "true"
        agent.skywalking.apache.org/agent.service_name: "systest]UATCLS01::javatest-gc"
    spec:
      containers:
      - image: sles12sp3_jdk8_javatest:20191022001
        imagePullPolicy: IfNotPresent
        name: javatest-gc
        ports:
        - containerPort: 80
          protocol: TCP
        resources:
          limits:
            cpu: "4"
            memory: 8Gi
          requests:
            cpu: "1"
            memory: 2Gi
---
kubectl -n systest get deploy javatest-gc

NAME          READY   UP-TO-DATE   AVAILABLE   AGE
javatest-gc   0/1        0                     0                   1h
kubectl -n systest get deploy javatest-gc -o yaml
...
status:
...
    message: 'pods "javatest-gc-6cb46784d6-l2wkp" is forbidden: failed quota: resourcequota:
      must specify limits.cpu,limits.memory,requests.cpu,requests.memory'
    reason: FailedCreate
...

What you expected to happen

I expect SWCK injection can work normally when the k8s namespace is set resourcequota.

How to reproduce

  1. create a namespace
  2. set resourcequota in the namespace
  3. deploy a java application with SWCK injecting java agent

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Labels

SWCKApache SkyWalking Cloud on KubernetesfeatureNew feature

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions