Target of `kubernetes-exec` Test action defaults w...
# 🌱|help-and-getting-started
f
When I switched a Deploy action of type Kubernetes from using local manifests to a Kustomization living in a remote configuration repository, my tests running as kubernetes-exec began failing to target the specified containerName, instead defaulting to a different container. I fixed this by setting a default container annotation on the Deployment, but this feels like a hack. Is this a known issue? Further, setting
spec.defaultTarget
also fails. Only the annotation fixes it. I will note that directly performing
kubectl exec <podname> -c <containername> -- <test command
correctly executes the test.
Deploy action:
Copy code
yaml
---
kind: Deploy
type: kubernetes
name: tunnel
description: Chisel tunnel server and tunnel manager deployment
variables:
  apphost: ${environment.namespace}${var.baseHostName}
dependencies:
  - build.tunnel
  - build.tunnel-manager
  - deploy.redis
spec:
  defaultTarget:
    kind: Deployment
    name: tunnel-server
    containerName: tunnel-manager
  portForwards:
    - name: tunnel-manager
      resource: Deployment/tunnel-server
      targetPort: 8000
      localPort: 50001
  sync:
    paths:
      - target:
          kind: Deployment
          name: tunnel-server
          containerName: tunnel-manager
        sourcePath: "./tunnel-manager"
        containerPath: "/app"
        mode: "one-way-replica"
  files:
    - secrets.yml
  manifests:
    # NOTE: These are DEV-ONLY Manifests
    - apiVersion: v1
      kind: ConfigMap
      metadata:
        name: tunnel-manager-config
        namespace: kraken-${environment.namespace}
      data:
        TUNNEL_MANAGER_NAMESPACE: kraken-${environment.namespace}
        ...
    - apiVersion: networking.k8s.io/v1
      kind: Ingress
      ...
  kustomize:
    path: ssh://git@github.com/ScaleComputing/kraken-configuration/tunnel/tunnel-service/overlays/development
  patchResources:
    - kind: Deployment
      name: tunnel-server
      strategy: strategic
      patch:
        spec:
          replicas: 1
          template:
            # metadata:
            #   annotations:
            #     kubectl.kubernetes.io/default-container: "tunnel-manager"
            spec:
              containers:
              - name: chisel-server
                image: ${actions.build.tunnel.outputs.deploymentImageId}
              - name: tunnel-manager
                image: ${actions.build.tunnel-manager.outputs.deploymentImageId}
                command:
                  - "hatch"
                args:
                  - "run"
                  - "api"
Test action:
Copy code
yaml
---
kind: Test
type: kubernetes-exec
name: tunnel-unit
build: tunnel
description: Run unit tests
dependencies:
  - deploy.tunnel
spec:
  resource:
    kind: Deployment
    name: tunnel-server
    containerName: tunnel-manager
  command:
  - hatch 
  - run 
  - test 
  - --
  - -m
  - "unit"
f
Hello @fresh-yak-35965 Thanks for flagging this bug! It is indeed an oversight, that we did not pass the
containerName
on from the test action. This PR fixes this https://github.com/garden-io/garden/pull/6682 With this fix it will be sufficient to specifiy the container name in your
tunnel-unit
test action.
f
@freezing-pharmacist-34446 Amazing. Thanks!
5 Views