-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add build rules and instructions for enabling Istio sidecar injection #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
068dbbc
Upgrade istio to v0.6.0
ian-mi 6cc0b6a
Add build rules for setting up istio's automatic sidecar injector.
ian-mi 8798f9b
Remove fluentd sidecar.
ian-mi b60a867
Set annotations to explicitly enable/disable sidecar injection.
ian-mi b33b56f
Document steps for enabling Istio sidecar injection.
ian-mi 4fed6ef
Merge branch 'master' of github.com:elafros/elafros into istio-inject…
ian-mi d0f6d16
Respect the cluster override when fetching CA bundle.
ian-mi ba17a76
Rename ca_bundle rule to cluster_ca_bundle.
ian-mi 6e379b9
Remove unnecessary kind from istio-sidecar-injector-configmap.
ian-mi 4d0a9b1
Merge branch 'master' of github.com:elafros/elafros into istio-inject…
ian-mi 080a197
Use --namespace instead of -n in ca_bundle.bzl
ian-mi 004c2fa
Change istio build target to disable istio sidecar injection.
ian-mi ad00e62
Rename ca_bundle rule to cluster_ca_bundle.
ian-mi 224846d
Merge branch 'master' of github.com:elafros/elafros into istio-inject…
ian-mi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| genrule( | ||
| name = "gen-ca-bundle", | ||
| srcs = ["client-ca-file"], | ||
| outs = ["ca-bundle"], | ||
| cmd = "base64 <$< | tr -d '\n' >$@", | ||
| visibility = ["//visibility:public"], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| def _cluster_ca_bundle_impl(ctx): | ||
| ctx.symlink(Label("//:BUILD.ca_bundle"), "BUILD") | ||
| cluster = ctx.execute([ | ||
| "sh", "-c", | ||
| "grep STABLE_K8S_CLUSTER bazel-out/stable-status.txt | cut -d' ' -f 2"]).stdout | ||
|
|
||
| result = ctx.execute([ | ||
| "kubectl", "get", "configmap", | ||
| "--namespace=kube-system", | ||
| "extension-apiserver-authentication", | ||
| "-o=jsonpath={.data.client-ca-file}", | ||
| "--cluster=" + cluster]) | ||
|
|
||
| if result.return_code != 0: | ||
| fail("Failed to get ca bundle: %s" % result.stderr) | ||
|
|
||
| ctx.file("client-ca-file", content=result.stdout) | ||
|
|
||
| cluster_ca_bundle = repository_rule( | ||
| implementation = _cluster_ca_bundle_impl, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| def _disable_policy_impl(ctx): | ||
| ctx.actions.expand_template( | ||
| template=ctx.file.template, | ||
| output=ctx.outputs.out, | ||
| substitutions={ | ||
| "policy: enabled": "policy: disabled", | ||
| }) | ||
|
|
||
| disable_policy = rule( | ||
| implementation=_disable_policy_impl, | ||
| attrs={ | ||
| "template": attr.label(allow_files=True, single_file=True), | ||
| }, | ||
| outputs={"out": "%{name}.yaml"} | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes the current
kubectlcontext is where you want it vs. an explicit cluster argument. You should at least make the docs note this (or how to check that their cluster variable$K8S_CLUSTER_OVERRIDEmatches the current contextkubectl config current-context)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking inside of this script, this looks like it would be non-trivial to incorporate into our
k8s_objectrules, but I think it's doable through some custom logic (and I'd like to keep our setup to:everything.apply). Can you open an issue and assign it to me?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, here's an issue describing kind of what I had in mind: bazelbuild/rules_k8s#88