Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Merge #84 into master #89

Merged
merged 4 commits into from
Dec 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ for setting up authentication:
gcloud container clusters get-credentials <CLUSTER NAME>
```

## Dependencies

The rules will require the `kubectl` tool when executing the `run` action from
bazel. If GKE is used, also the `gcloud` sdk need to be installed.

## Examples

### Basic "deployment" objects
Expand Down Expand Up @@ -405,7 +410,8 @@ A rule for interacting with Kubernetes objects.
<p><code>string, optional</code></p>
<p>The namespace on the cluster within which the actions are
performed.</p>
<p><b>If this is omitted, it will default to
<p><b>If this is omitted, it will default to the value specified
in the template or if also unspecified there, to the value
<code>"default"</code>.</b></p>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion k8s/apply.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ function guess_runfiles() {
RUNFILES="${PYTHON_RUNFILES:-$(guess_runfiles)}"

PYTHON_RUNFILES=${RUNFILES} %{resolve_script} | \
kubectl --cluster="%{cluster}" --namespace="%{namespace}" apply -f -
kubectl --cluster="%{cluster}" %{namespace_arg} apply -f -
2 changes: 1 addition & 1 deletion k8s/create.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ RUNFILES="${PYTHON_RUNFILES:-$(guess_runfiles)}"
# TODO(mattmoor): Should we create namespaces that do not exist?

PYTHON_RUNFILES=${RUNFILES} %{resolve_script} | \
kubectl --cluster="%{cluster}" --namespace="%{namespace}" create -f -
kubectl --cluster="%{cluster}" %{namespace_arg} create -f -
3 changes: 1 addition & 2 deletions k8s/delete.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ function guess_runfiles() {

RUNFILES="${PYTHON_RUNFILES:-$(guess_runfiles)}"

kubectl --cluster="%{cluster}" --namespace="%{namespace}" delete \
-f %{unresolved}
kubectl --cluster="%{cluster}" %{namespace_arg} delete -f %{unresolved}
4 changes: 2 additions & 2 deletions k8s/describe.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ RUNFILES="${PYTHON_RUNFILES:-$(guess_runfiles)}"

RESOURCE_NAME=$(kubectl create --dry-run -f "%{unresolved}" | cut -d'"' -f 2)

kubectl --cluster="%{cluster}" --namespace="%{namespace}" \
describe %{kind} "${RESOURCE_NAME}"
kubectl --cluster="%{cluster}" %{namespace_arg} describe %{kind} \
"${RESOURCE_NAME}"
5 changes: 4 additions & 1 deletion k8s/object.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,12 @@ def _common_impl(ctx):
namespace_arg = "$(cat %s)" % _runfiles(ctx, namespace_file)
files += [namespace_file]

if namespace_arg:
namespace_arg = "--namespace=\"" + namespace_arg + "\""

substitutions = {
"%{cluster}": cluster_arg,
"%{namespace}": namespace_arg,
"%{namespace_arg}": namespace_arg,
"%{kind}": ctx.attr.kind,
}

Expand Down
2 changes: 1 addition & 1 deletion k8s/replace.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ function guess_runfiles() {
RUNFILES="${PYTHON_RUNFILES:-$(guess_runfiles)}"

PYTHON_RUNFILES=${RUNFILES} %{resolve_script} | \
kubectl --cluster="%{cluster}" --namespace="%{namespace}" replace -f -
kubectl --cluster="%{cluster}" %{namespace_arg} replace -f -