google / kctf

kCTF is a Kubernetes-based infrastructure for CTF competitions. For documentation, see
https://google.github.io/kctf/
Apache License 2.0
665 stars 73 forks source link

custom resource specs (cpu/mem requests/limits) of healthcheck container in challenge manifest has no effect #387

Open phongvq opened 1 year ago

phongvq commented 1 year ago

Summary

Regardless of resources spec (cpu / mem requests / limits) of healthcheck container in challenge manifest,

# challenge manifest

apiVersion: kctf.dev/v1
kind: Challenge
metadata:
  annotations: {}
  name: asf
  namespace: default
status:
  health: healthy
  status: Running
spec:
  deployed: true
  healthcheck:
    enabled: true
    image: >-
      aaaa
  image: >-
     aaaa
  network:
     ports:
      - domains:
          - adsf.a.a.
        name: ext
        protocol: TCP
        targetPort: 1337
    public: false
  podTemplate:
    template:
      spec:
        containers:
          - name: challenge
            resources:
              requests:
                cpu: 1m
                memory: 1Mi
          - name: healthcheck
            resources:
              requests:
                cpu: 1m
                memory: 1Mi

resource spec of container in deployment is always set as below.

# created deployment

    - name: healthcheck
      image: >-
        abc
      resources:
        limits:
          cpu: '1'
        requests:
          cpu: 50m

Expected behaviour

Resource specs of healthcheck container in deployment must be same as what specified in challenge.yaml.

phongvq commented 1 year ago

I suspect this line of code https://github.com/google/kctf/blob/v1/kctf-operator/controllers/deployment/deployment-with-healthcheck.go#L64 caused the issue (hard-coded healthcheck container resource spec)