0

I can't seem to find a simple answer to my question,

how to use linkerd inject command / options to add when using helm to install a package, e.g. like postgres?

I have done it with another package but that was by adding the annotation command to a values file and supplying that when running the helm install command.

With istio, all I have to do is to add a label on the namespace and it works?

So I started to look into adding the annotation to the namespaces I am working with, using the kubectl create namespace command?

However, I cant seem to find a way to add any annotation at the point of creating a namespace, unless I use a file.

So, I either need a way to add this annotation to the namespace with the create command or when installing packages with helm?

Thanks,

rock'n rolla
  • 1,883
  • 1
  • 13
  • 19
C0ol_Cod3r
  • 909
  • 2
  • 15
  • 35

1 Answers1

6

I think there are a couple of ways to do this. It all depends on what you are trying to achieve and how you'd like to manage your underlying infrastructure.

I assume you want to automate the installation of helm charts. If you are going to create the namespace using kubectl create namespace then you might be able to follow that up with kubectl annotate <created-namespace> "linkerd.io/inject=enabled".

Alternatively, you can make use of the Linkerd CLI and use the inject command provided -- the workflow here would involve a combination of kubectl and linkerd commands so I'm not sure it's what you're looking for. Nonetheless, you can do something like kubectl create namespace <my-namespace> -o yaml | linkerd inject - | kubectl apply -f -.

Last but not least, if you can use kubectl create namespace then you might be able to pipe the namespace manifest to kubectl directly and call it a day? You can use something similar to the snippet below:

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
  name: foo
  annotations:
    linkerd.io/inject: enabled
EOF
moonkotte
  • 3,661
  • 2
  • 10
  • 25
mateidavid
  • 165
  • 6
  • Many thanks - these look like good options - mostly the 1st and 2nd ones, I give them a try and get back to you. And yes I am sort of trying to automate it, but its nothing more than a bash script with some commands. – C0ol_Cod3r Jun 17 '21 at 15:10
  • The first two options dont seem to work at all. with the 1st option, it just returns an error, ```at lest one annotation update is required``` – C0ol_Cod3r Jun 17 '21 at 16:03
  • Hm, it would be helpful to clarify maybe how you run these commands. For example, with the first approach, I can get it to work without a problem from my shell. `kubectl create namespace foobar; kubectl annotate namespace foobar "linkerd.io/inject=enabled"` -- verifying the namespace with `kubectl get namespace foobar -o yaml | grep "linkerd"` gives me the correct output (linkerd.io/inject: enabled). It would also be helpful to know how the second approach errors. – mateidavid Jun 17 '21 at 16:23
  • Sorry my bad ;( i was using ```linkerd.io/inject: enabled``` and not ```linkerd.io/inject=enabled``` and did to know you had to have the ```namespace``` keyword with the annotate command. But I understand, as i am guesting a little here, all sorts of different types can have annotations? and not just namespaces – C0ol_Cod3r Jun 17 '21 at 17:18