tor-controller icon indicating copy to clipboard operation
tor-controller copied to clipboard

[BUG] Kustomize defined secrets is not used by OnionService::privateKeySecret

Open alf0ns3 opened this issue 9 months ago • 0 comments

Describe the bug When importing a privateKeySecret generated by Kustomize on a new OnionService, the controller creates a new secret based on the name provided and so the hostname is random. It is due to Kustomize which append a suffix hash to the secret name, while the Tor Controller is not aware of the new name.

To Reproduce

# kustomization.yaml
namespace: test

secretGenerator:
  - name: onion-secrets
    type: "tor.k8s.torproject.org/onion-v3"
    files:
      - privateKeyFile=secrets/hs_ed25519_secret_key
      - publicKeyFile=secrets/hs_ed25519_public_key
      - onionAddress=secrets/hostname

#generatorOptions:
#  disableNameSuffixHash: true

resources:
  - onion-service.yaml
  - deployment.yaml # definition of the http-app



# onion-service.yaml
---
apiVersion: tor.k8s.torproject.org/v1alpha2
kind: OnionService
metadata:
  name: onion-service
spec:
  version: 3
  rules:
    - port:
        number: 80
      backend:
        service:
          name: http-app
          port:
            number: 80
  privateKeySecret:
    name: onion-secrets

The Tor Controller creates the secret onion-secrets with 5 entries (Tor v2&v3), while Kustomize creates the desired secrets onion-secrets-52gc9c9ccd.

kubectl -n test get secrets
onion-secrets              tor.k8s.torproject.org/onion-v3                5      15m
onion-secrets-52gc9c9ccd   tor.k8s.torproject.org/onion-v3                3      14m

By using the Kustomize disableNameSuffixHash config, it is woking as expected, such as using the hashed name on the OnionService definition.

Expected behavior

When using a Kustomize defined secret, the Tor Controller should use it automatically with the suffix hash.

Additional information

System (please complete the following information):

  • Platform: minikube v1.34.0
  • Version: master branch ( aae11b5b3454c58ac1fa3d8036097bfedc72cc0d )

Additional context

alf0ns3 avatar Jan 22 '25 10:01 alf0ns3