Skip to content

Commit

Permalink
Rename default branch
Browse files Browse the repository at this point in the history
  • Loading branch information
guidowb committed Sep 25, 2023
1 parent 34a2c44 commit fc9437b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion 1.0-Upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* There are breaking changes in the public API (such as the renaming of the `KubernetesDeploy` namespace to `Krane`, and the change in default values for different arguments of the public interface).
* StatsD metrics will now be generated with the `krane` prefix.
* `krane deploy` now considers all namespaced resources eligible for pruning, including
custom resources. See [blacklist](https://github.com/Shopify/krane/blob/master/lib/krane/cluster_resource_discovery.rb#L20) for exceptions.
custom resources. See [blacklist](https://github.com/Shopify/krane/blob/main/lib/krane/cluster_resource_discovery.rb#L20) for exceptions.
* `kubernetes-deploy` (now `krane deploy`) / `DeployTask` can no longer deploy global (non-namespaced) resources. A new command called `krane global-deploy` and a related class called `GlobalDeployTask` were added to replace that feature.
* `krane deploy` will not render erb templates. Use `krane render | krane deploy --stdin` to reproduce this functionality.
* If you attempt to install two gems that have conflicting executables, `gem install` will warn you but the most recently installed one will win.
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ It seems an issue when too many pods are referencing the same secret/configmap h
# 1.0.0

We've renamed the gem and cli to Krane.
See our [migration guide](https://github.com/Shopify/krane/blob/master/1.0-Upgrade.md) to help navigate the breaking changes.
See our [migration guide](https://github.com/Shopify/krane/blob/main/1.0-Upgrade.md) to help navigate the breaking changes.

## 1.0.0.pre.2

Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The following is a set of guidelines for contributing to krane. Please take a mo
* [CI (External contributors)](#ci-external-contributors)
## Code of Conduct

This project and everyone participating in it are governed by the [Code of Conduct](https://github.com/Shopify/krane/blob/master/CODE_OF_CONDUCT.md).
This project and everyone participating in it are governed by the [Code of Conduct](https://github.com/Shopify/krane/blob/main/CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code. Please report unacceptable
behavior to [krane@shopify.com](mailto:krane@shopify.com).

Expand Down Expand Up @@ -95,9 +95,9 @@ This gem uses subclasses of `KubernetesResource` to implement custom success/fai
* `deploy_failed?`
3. Adjust the `TIMEOUT` constant to an appropriate value for this type.
4. Add the new class to list of resources in
[`deploy_task.rb`](https://github.com/Shopify/krane/blob/master/lib/krane/deploy_task.rb#L8)
5. Add the new resource to the [prune whitelist](https://github.com/Shopify/krane/blob/master/lib/krane/deploy_task.rb#L81)
6. Add a basic example of the type to the hello-cloud [fixture set](https://github.com/Shopify/krane/tree/master/test/fixtures/hello-cloud) and appropriate assertions to `#assert_all_up` in [`hello_cloud.rb`](https://github.com/Shopify/krane/blob/master/test/helpers/fixture_sets/hello_cloud.rb). This will get you coverage in several existing tests, such as `test_full_hello_cloud_set_deploy_succeeds`.
[`deploy_task.rb`](https://github.com/Shopify/krane/blob/main/lib/krane/deploy_task.rb#L8)
5. Add the new resource to the [prune whitelist](https://github.com/Shopify/krane/blob/main/lib/krane/deploy_task.rb#L81)
6. Add a basic example of the type to the hello-cloud [fixture set](https://github.com/Shopify/krane/tree/main/test/fixtures/hello-cloud) and appropriate assertions to `#assert_all_up` in [`hello_cloud.rb`](https://github.com/Shopify/krane/blob/main/test/helpers/fixture_sets/hello_cloud.rb). This will get you coverage in several existing tests, such as `test_full_hello_cloud_set_deploy_succeeds`.
7. Add tests for any edge cases you foresee.

### Contributor License Agreement
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# krane [![Build status](https://badge.buildkite.com/35c56e797c3bbd6ba50053aefdded0715898cd8e8c86f7e462.svg?branch=master)](https://buildkite.com/shopify/krane)
# krane [![Build status](https://badge.buildkite.com/35c56e797c3bbd6ba50053aefdded0715898cd8e8c86f7e462.svg?branch=main)](https://buildkite.com/shopify/krane)

> This project used to be called `kubernetes-deploy`. Check out our [migration guide](https://github.com/Shopify/krane/blob/master/1.0-Upgrade.md) for more information including details about breaking changes.
> This project used to be called `kubernetes-deploy`. Check out our [migration guide](https://github.com/Shopify/krane/blob/main/1.0-Upgrade.md) for more information including details about breaking changes.

`krane` is a command line tool that helps you ship changes to a Kubernetes namespace and understand the result. At Shopify, we use it within our much-beloved, open-source [Shipit](https://github.com/Shopify/shipit-engine#kubernetes) deployment app.
Expand Down Expand Up @@ -337,7 +337,7 @@ status:

### Deploy walkthrough

Let's walk through what happens when you run the `deploy` task with [this directory of templates](https://github.com/Shopify/krane/tree/master/test/fixtures/hello-cloud). This particular example uses ERB templates as well, so we'll use the [krane render](#krane-render) task to achieve that.
Let's walk through what happens when you run the `deploy` task with [this directory of templates](https://github.com/Shopify/krane/tree/main/test/fixtures/hello-cloud). This particular example uses ERB templates as well, so we'll use the [krane render](#krane-render) task to achieve that.

You can test this out for yourself by running the following command:

Expand Down Expand Up @@ -404,7 +404,7 @@ In this phase, we:

Just like in the previous phase, we essentially run `kubectl apply` on those templates and periodically check the cluster for the current status of each resource so we can display error or success information.

If pruning is enabled (which, again, is the default), any [kind not listed in the blacklist](https://github.com/Shopify/krane/blob/master/lib/krane/cluster_resource_discovery.rb#L20) that we can find in the namespace but not in the templates will be removed. A particular message about pruning will be printed in the next phase if any resource matches this criteria.
If pruning is enabled (which, again, is the default), any [kind not listed in the blacklist](https://github.com/Shopify/krane/blob/main/lib/krane/cluster_resource_discovery.rb#L20) that we can find in the namespace but not in the templates will be removed. A particular message about pruning will be printed in the next phase if any resource matches this criteria.

#### Result

Expand Down Expand Up @@ -654,13 +654,13 @@ This is a limitation of the current implementation.
# Contributing
We :heart: contributors! To make it easier for you and us we've written a
[Contributing Guide](https://github.com/Shopify/krane/blob/master/CONTRIBUTING.md)
[Contributing Guide](https://github.com/Shopify/krane/blob/main/CONTRIBUTING.md)
You can also reach out to us on our slack channel, #krane, at https://kubernetes.slack.com. All are welcome!
## Code of Conduct
Everyone is expected to follow our [Code of Conduct](https://github.com/Shopify/krane/blob/master/CODE_OF_CONDUCT.md).
Everyone is expected to follow our [Code of Conduct](https://github.com/Shopify/krane/blob/main/CODE_OF_CONDUCT.md).
# License
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/slow-cloud/web-deploy-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: web
labels:
name: web
branch: master
branch: main
app: slow-cloud
annotations:
shipit.shopify.io/restart: "true"
Expand Down
30 changes: 15 additions & 15 deletions test/integration/krane_deploy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ def test_pruning_disabled
def test_selector
# Deploy the same thing twice with a different selector
assert_deploy_success(deploy_fixtures("branched", subset: ["web.yml.erb"],
bindings: { "branch" => "master" },
selector: Krane::LabelSelector.parse("branch=master"),
bindings: { "branch" => "main" },
selector: Krane::LabelSelector.parse("branch=main"),
render_erb: true))
assert_logs_match("Using resource selector branch=master")
assert_logs_match("Using resource selector branch=main")
assert_deploy_success(deploy_fixtures("branched", subset: ["web.yml.erb"],
bindings: { "branch" => "staging" },
selector: Krane::LabelSelector.parse("branch=staging"),
Expand All @@ -169,31 +169,31 @@ def test_selector
deployments = apps_v1_kubeclient.get_deployments(namespace: @namespace, label_selector: "app=branched")

assert_equal(2, deployments.size)
assert_equal(%w(master staging), deployments.map { |d| d.metadata.labels.branch }.sort)
assert_equal(%w(main staging), deployments.map { |d| d.metadata.labels.branch }.sort)

# Run again without selector to verify pruning works
assert_deploy_success(deploy_fixtures("branched", bindings: { "branch" => "master" }, render_erb: true))
assert_deploy_success(deploy_fixtures("branched", bindings: { "branch" => "main" }, render_erb: true))
deployments = apps_v1_kubeclient.get_deployments(namespace: @namespace, label_selector: "app=branched")
# Filter out pruned resources pending deletion
deployments.select! { |deployment| deployment.metadata.deletionTimestamp.nil? }

assert_equal(1, deployments.size)
assert_equal("master", deployments.first.metadata.labels.branch)
assert_equal("main", deployments.first.metadata.labels.branch)
end

def test_selector_as_filter
# Deploy only the resource matching the selector without validation error
assert_deploy_success(deploy_fixtures("slow-cloud", subset: ['web-deploy-1.yml', 'web-deploy-3.yml'],
selector: Krane::LabelSelector.parse("branch=master"),
selector: Krane::LabelSelector.parse("branch=main"),
selector_as_filter: true))
assert_logs_match_all([
"Using resource selector branch=master",
"Using resource selector branch=main",
"Only deploying resources filtered by labels in selector",
], in_order: true)
# Ensure only the selected resource is deployed
deployments = apps_v1_kubeclient.get_deployments(namespace: @namespace)
assert_equal(1, deployments.size)
assert_equal("master", deployments.first.metadata.labels.branch)
assert_equal("main", deployments.first.metadata.labels.branch)

# Deploy another resource with a different selector
assert_deploy_success(deploy_fixtures("slow-cloud", subset: ['web-deploy-1.yml', 'web-deploy-3.yml'],
Expand All @@ -206,9 +206,9 @@ def test_selector_as_filter
# Ensure the not selected resource is not pruned
deployments = apps_v1_kubeclient.get_deployments(namespace: @namespace)
assert_equal(2, deployments.size)
deployments = apps_v1_kubeclient.get_deployments(namespace: @namespace, label_selector: "branch=master")
deployments = apps_v1_kubeclient.get_deployments(namespace: @namespace, label_selector: "branch=main")
assert_equal(1, deployments.size)
assert_equal("master", deployments.first.metadata.labels.branch)
assert_equal("main", deployments.first.metadata.labels.branch)
# Ensure the selected resource is deployed
deployments = apps_v1_kubeclient.get_deployments(namespace: @namespace, label_selector: "branch=staging")
assert_equal(1, deployments.size)
Expand All @@ -222,7 +222,7 @@ def test_mismatched_selector
/Using resource selector branch=staging/,
/Template validation failed/,
/Invalid template: Deployment/,
/selector branch=staging does not match labels name=web,branch=master,app=slow-cloud/,
/selector branch=staging does not match labels name=web,branch=main,app=slow-cloud/,
/> Template content:/,
], in_order: true)
end
Expand Down Expand Up @@ -669,7 +669,7 @@ def test_can_deploy_template_dir_with_only_secrets_ejson
end

def test_ejson_works_with_label_selectors
value = "master"
value = "main"
selector = Krane::LabelSelector.parse("branch=#{value}")
ejson_cloud = FixtureSetAssertions::EjsonCloud.new(@namespace)
ejson_cloud.create_ejson_keys_secret
Expand Down Expand Up @@ -1475,12 +1475,12 @@ def test_apply_failure_with_sensitive_resources_not_leak_sensitive_content
end

def test_validation_failure_on_sensitive_resources_does_not_print_template
selector = Krane::LabelSelector.parse("branch=master")
selector = Krane::LabelSelector.parse("branch=main")
assert_deploy_failure(deploy_fixtures("hello-cloud", subset: %w(secret.yml), selector: selector))
assert_logs_match_all([
"Template validation failed",
"Invalid template: Secret-hello-secret",
"selector branch=master passed in, but no labels were defined",
"selector branch=main passed in, but no labels were defined",
], in_order: true)
refute_logs_match("password")
refute_logs_match("YWRtaW4=")
Expand Down

0 comments on commit fc9437b

Please sign in to comment.