istio / old_issues_repo

Deprecated issue-tracking repo, please post new issues or feature requests to istio/istio instead.
37 stars 9 forks source link

Istio api to inject envoy into pods instead of istio command line #148

Closed JasmithaMeka closed 6 years ago

JasmithaMeka commented 6 years ago

Is this a BUG or FEATURE REQUEST?: NEED HELP

Did you review existing epics or issues to identify if this already being worked on? (please try to add the correct labels and epics): Y

Bug: N

What Version of Istio and Kubernetes are you using, where did you get Istio from, Installation details

istioctl version - 0.4.0
kubectl version - 1.7.8

Is Istio Auth enabled or not ? Did you install istio.yaml, istio-auth.yaml.... I have installed istio.yaml

What happened and What you expected to happen: I want to inject side cars using an API instead of istio command line. When I tried to execute istioctl command with verbose mode(--v=9). I found out it is accessing only one API to get istio ConfigMap. I have gone through code flow of inject.go. What exactly happens when "istioctl kube-inject -f .yaml" ? Is logger not mentioned for that particular part ? How can I learn which API is calling inject.go ? is there a way to see the flow ? Can I inject envoy to pods using an API (curl http call) ?

I have created Objects(RouteRule) using following api $curl -X POST -d @(file-name).yaml http://localhost:(kubectl-proxy-port)/apis/config.istio.io/v1alpha2/namespaces/default/routerules

Is it the right way? Is there any other standard way to do it using Istio API s?

What you expected to happen I am expecting a response something like this where I get to know which API command is accessing

$ kubectl --v=9 version 
I0103 17:57:36.260584   44876 loader.go:357] Config loaded from file /Users/jasmitha/.kube/config
I0103 17:57:36.261905   44876 round_trippers.go:417] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.8.4 (darwin/amd64) kubernetes/9befc2b" https://35.192.173.49/version
I0103 17:57:37.448168   44876 round_trippers.go:436] GET https://35.192.173.49/version 200 OK in 1186 milliseconds
I0103 17:57:37.448190   44876 round_trippers.go:442] Response Headers:
I0103 17:57:37.448195   44876 round_trippers.go:445]     Content-Type: application/json
I0103 17:57:37.448200   44876 round_trippers.go:445]     Content-Length: 267
I0103 17:57:37.448204   44876 round_trippers.go:445]     Date: Wed, 03 Jan 2018 12:27:09 GMT
I0103 17:57:37.450465   44876 request.go:836] Response Body: {
  "major": "1",
  "minor": "7+",
  "gitVersion": "v1.7.8-gke.0",
  "gitCommit": "a7061d4b09b53ab4099e3b5ca3e80fb172e1b018",
  "gitTreeState": "clean",
  "buildDate": "2017-10-10T18:48:45Z",
  "goVersion": "go1.8.3",
  "compiler": "gc",
  "platform": "linux/amd64"
}
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.4", GitCommit:"9befc2b8928a9426501d3bf62f72849d5cbcd5a3", GitTreeState:"clean", BuildDate:"2017-11-20T05:28:34Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"7+", GitVersion:"v1.7.8-gke.0", GitCommit:"a7061d4b09b53ab4099e3b5ca3e80fb172e1b018", GitTreeState:"clean", BuildDate:"2017-10-10T18:48:45Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
ayj commented 6 years ago

kube-inject is purely a client-side function. There is no server-side callable API for injection. The istio ConfigMap is only accessed to retrieve some mesh-level configuration.

See https://istio.io/docs/setup/kubernetes/sidecar-injection.html#automatic-sidecar-injection for how we do handle server-side injection.

JasmithaMeka commented 6 years ago

Hi Ayj, Thanks for the quick reply

I want to inject envoy from my Go application. Thats why I was asking about API. If possible could you send a snippet that is triggered (on execution of istioctl kube-inject -f finename.yaml) which calls function that injects envoy? Is there any other way to inject from an application if not to do it automatically or using Istio command line ?

ayj commented 6 years ago

Injection appends additional containers and volumes to the pod template spec. The code for this is in intoObject and injectIntoSpec. This could be refactored into a more consumable/public package but there aren't any plans for that right now. Can you provide more background on the problem you're trying to solve and why the existing command line and automatic options are not sufficient?

JasmithaMeka commented 6 years ago

Idea is to inject side cars using my custom GoLang program. If I execute command using code, I wont be sure if it is executed successfully or not. Yes, I can take response and check but Im just wondering if there is any other way to do it.

josephburnett commented 6 years ago

+1 to providing an API for Istio Envoy injection. I already have the pod spec in a CRD controller. I would rather just inject with a go function there, than to setup yet another webhook.

ayj commented 6 years ago

We could export injectionData(). You'd need to provide the sidecar template and proxy/mesh configurations.

ayj commented 6 years ago

Issue moved to istio/istio #3816 via ZenHub