Skip to content

Commit

Permalink
Merge branch 'master' into serde-apiresource
Browse files Browse the repository at this point in the history
  • Loading branch information
clux authored Aug 4, 2021
2 parents d84e066 + a0d80c1 commit db5eed7
Show file tree
Hide file tree
Showing 19 changed files with 225 additions and 193 deletions.
311 changes: 156 additions & 155 deletions CHANGELOG.md

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Contributing Guide

This document describes the requirements for committing to this repository.

## Developer Certificate of Origin (DCO)

In order to contribute to this project, you must sign each of your commits to
attest that you have the right to contribute that code. This is done with the
`-s`/`--signoff` flag on `git commit`. More information about DCO can be found
[here](https://developercertificate.org/)

## Pull Request Management

All code that is contributed to kube-rs must go through the Pull Request (PR)
process. To contribute a PR, fork this project, create a new branch, make
changes on that branch, and then use GitHub to open a pull request with your
changes.

Every PR must be reviewed by at least one [Core Maintainer](https://github.com/orgs/kube-rs/teams/core-maintainers) of the project. Once
a PR has been marked "Approved" by a Core Maintainer (and no other core
maintainer has an open "Rejected" vote), the PR may be merged. While it is fine
for non-maintainers to contribute their own code reviews, those reviews do not
satisfy the above requirement.

## Code of Conduct

This project has adopted the [CNCF Code of
Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md).

## Contact
You can ask general questions / share ideas / query the community at the [kube-rs discussions forum](https://github.com/kube-rs/kube-rs/discussions).
You can reach the maintainers of this project at [#kube](https://discord.gg/tokio) channel on the Tokio discord.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2014 The Kubernetes Authors.
Copyright 2018 The kube-rs Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# kube-rs
[![CI](https://github.com/clux/kube-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/clux/kube-rs/actions/workflows/ci.yml)
[![CI](https://github.com/kube-rs/kube-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/kube-rs/kube-rs/actions/workflows/ci.yml)
[![Client Capabilities](https://img.shields.io/badge/Kubernetes%20client-Silver-blue.svg?style=plastic&colorB=C0C0C0&colorA=306CE8)](http://bit.ly/kubernetes-client-capabilities-badge)
[![Client Support Level](https://img.shields.io/badge/kubernetes%20client-beta-green.svg?style=plastic&colorA=306CE8)](http://bit.ly/kubernetes-client-support-badge)
[![Crates.io](https://img.shields.io/crates/v/kube.svg)](https://crates.io/crates/kube)
Expand All @@ -19,13 +19,13 @@ kube-runtime = "0.58.1"
k8s-openapi = { version = "0.12.0", default-features = false, features = ["v1_20"] }
```

[Features are available](https://github.com/clux/kube-rs/blob/master/kube/Cargo.toml#L18).
[Features are available](https://github.com/kube-rs/kube-rs/blob/master/kube/Cargo.toml#L18).

We recommend turning off `default-features` for `k8s-openapi` to speed up your compilation.

## Upgrading
Please check the [CHANGELOG](./CHANGELOG.md) when upgrading.
All crates herein are versioned and [released](./release.toml) together to guarantee [compatibility before 1.0](https://github.com/clux/kube-rs/issues/508).
All crates herein are versioned and [released](./release.toml) together to guarantee [compatibility before 1.0](https://github.com/kube-rs/kube-rs/issues/508).

## Usage
See the [examples directory](./examples) for how to use any of these crates.
Expand All @@ -35,9 +35,9 @@ See the [examples directory](./examples) for how to use any of these crates.

Official examples:

- [version-rs](https://github.com/clux/version-rs): super lightweight reflector deployment with actix 2 and prometheus metrics
- [version-rs](https://github.com/kube-rs/version-rs): super lightweight reflector deployment with actix 2 and prometheus metrics

- [controller-rs](https://github.com/clux/controller-rs): `Controller` owned by a `Manager` inside actix
- [controller-rs](https://github.com/kube-rs/controller-rs): `Controller` owned by a `Manager` inside actix

Real world users:

Expand Down Expand Up @@ -153,7 +153,7 @@ Controller::new(root_kind_api, ListParams::default())
Here `reconcile` and `error_policy` refer to functions you define. The first will be called when the root or child elements change, and the second when the `reconciler` returns an `Err`.

## Rustls
Kube has basic support ([with caveats](https://github.com/clux/kube-rs/issues?q=is%3Aissue+is%3Aopen+rustls)) for [rustls](https://github.com/ctz/rustls) as a replacement for the `openssl` dependency. To use this, turn off default features, and enable `rustls-tls`:
Kube has basic support ([with caveats](https://github.com/kube-rs/kube-rs/issues?q=is%3Aissue+is%3Aopen+rustls)) for [rustls](https://github.com/ctz/rustls) as a replacement for the `openssl` dependency. To use this, turn off default features, and enable `rustls-tls`:

```toml
[dependencies]
Expand All @@ -165,7 +165,7 @@ k8s-openapi = { version = "0.12.0", default-features = false, features = ["v1_20
This will pull in `rustls` and `hyper-rustls`.

## musl-libc
Kube will work with [distroless](https://github.com/clux/controller-rs/blob/master/Dockerfile), [scratch](https://github.com/constellation-rs/constellation/blob/27dc89d0d0e34896fd37d638692e7dfe60a904fc/Dockerfile), and `alpine` (it's also possible to use alpine as a builder [with some caveats](https://github.com/clux/kube-rs/issues/331#issuecomment-715962188)).
Kube will work with [distroless](https://github.com/kube-rs/controller-rs/blob/master/Dockerfile), [scratch](https://github.com/constellation-rs/constellation/blob/27dc89d0d0e34896fd37d638692e7dfe60a904fc/Dockerfile), and `alpine` (it's also possible to use alpine as a builder [with some caveats](https://github.com/kube-rs/kube-rs/issues/331#issuecomment-715962188)).

## License
Apache 2.0 licensed. See LICENSE for details.
2 changes: 1 addition & 1 deletion kube-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = [
]
edition = "2018"
license = "Apache-2.0"
repository = "https://github.com/clux/kube-rs"
repository = "https://github.com/kube-rs/kube-rs"
readme = "../README.md"

[features]
Expand Down
2 changes: 1 addition & 1 deletion kube-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ This crate is always re-exported from `kube` (even without features) under [`kub
See the **[kube-core API Docs](https://docs.rs/kube-core/)**

## Development
Help very welcome! We need generic utilities, helpers like those in apimachinery, testing improvements, or just documentation. See https://github.com/clux/kube-rs/labels/core
Help very welcome! We need generic utilities, helpers like those in apimachinery, testing improvements, or just documentation. See https://github.com/kube-rs/kube-rs/labels/core
2 changes: 1 addition & 1 deletion kube-core/src/dynamic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Contains types for using resource kinds not known at compile-time.
//!
//! For concrete usage see [examples prefixed with dynamic_](https://github.com/clux/kube-rs/tree/master/examples).
//! For concrete usage see [examples prefixed with dynamic_](https://github.com/kube-rs/kube-rs/tree/master/examples).
pub use crate::discovery::ApiResource;
use crate::{metadata::TypeMeta, resource::Resource};
Expand Down
2 changes: 1 addition & 1 deletion kube-core/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl ListParams {
/// Disables watch bookmarks to simplify watch handling
///
/// This is not recommended to use with production watchers as it can cause desyncs.
/// See [#219](https://github.com/clux/kube-rs/issues/219) for details.
/// See [#219](https://github.com/kube-rs/kube-rs/issues/219) for details.
pub fn disable_bookmarks(mut self) -> Self {
self.bookmarks = false;
self
Expand Down
4 changes: 2 additions & 2 deletions kube-core/src/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub enum WatchEvent<K> {
Modified(K),
/// Resource was deleted
Deleted(K),
/// Resource bookmark. `Bookmark` is a slimmed down `K` due to [#285](https://github.com/clux/kube-rs/issues/285).
/// Resource bookmark. `Bookmark` is a slimmed down `K` due to [#285](https://github.com/kube-rs/kube-rs/issues/285).
///
/// From [Watch bookmarks](https://kubernetes.io/docs/reference/using-api/api-concepts/#watch-bookmarks).
///
Expand All @@ -39,7 +39,7 @@ impl<K> Debug for WatchEvent<K> {
}
}

/// Slimed down K for [`WatchEvent::Bookmark`] due to [#285](https://github.com/clux/kube-rs/issues/285).
/// Slimed down K for [`WatchEvent::Bookmark`] due to [#285](https://github.com/kube-rs/kube-rs/issues/285).
///
/// Can only be relied upon to have metadata with resource version.
/// Bookmarks contain apiVersion + kind + basically empty metadata.
Expand Down
2 changes: 1 addition & 1 deletion kube-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = [
]
edition = "2018"
license = "Apache-2.0"
repository = "https://github.com/clux/kube-rs"
repository = "https://github.com/kube-rs/kube-rs"
readme = "../README.md"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion kube-derive/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ See the **[kube-derive API Docs](https://docs.rs/kube-derive/)**
See the `crd_` prefixed [examples](../examples) for more.

## Development
Help very welcome! Kubebuilder like features, testing improvement, openapi feature. See https://github.com/clux/kube-rs/labels/derive
Help very welcome! Kubebuilder like features, testing improvement, openapi feature. See https://github.com/kube-rs/kube-rs/labels/derive
12 changes: 6 additions & 6 deletions kube-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ mod custom_resource;
///
/// This example posts the generated `::crd` to the `CustomResourceDefinition` API.
/// After this has been accepted (few secs max), you can start using `foos` as a normal
/// kube `Api` object. See the `crd_` prefixed [examples](https://github.com/clux/kube-rs/blob/master/examples/)
/// kube `Api` object. See the `crd_` prefixed [examples](https://github.com/kube-rs/kube-rs/blob/master/examples/)
/// for details on this.
///
/// ## Required properties
Expand Down Expand Up @@ -161,18 +161,18 @@ mod custom_resource;
/// ## Customizing Schemas
/// Should you need to customize the schemas, you can use:
/// - [Serde/Schemars Attributes](https://graham.cool/schemars/examples/3-schemars_attrs/) (no need to duplicate serde renames)
/// - [`#[schemars(schema_with = "func")]`](https://graham.cool/schemars/examples/7-custom_serialization/) (e.g. like in the [`crd_derive` example](https://github.com/clux/kube-rs/blob/master/examples/crd_derive.rs))
/// - `impl JsonSchema` on a type / newtype around external type. See [#129](https://github.com/clux/kube-rs/issues/129#issuecomment-750852916)
/// - [`#[schemars(schema_with = "func")]`](https://graham.cool/schemars/examples/7-custom_serialization/) (e.g. like in the [`crd_derive` example](https://github.com/kube-rs/kube-rs/blob/master/examples/crd_derive.rs))
/// - `impl JsonSchema` on a type / newtype around external type. See [#129](https://github.com/kube-rs/kube-rs/issues/129#issuecomment-750852916)
///
/// In general, you will need to override parts of the schemas (for fields in question) when you are:
/// - **using complex enums**: enums do not currently generate [structural schemas](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#specifying-a-structural-schema), so kubernetes won't support them by default
/// - **customizing [merge-strategies](https://kubernetes.io/docs/reference/using-api/server-side-apply/#merge-strategy)** (e.g. like in the [`crd_derive_schema` example](https://github.com/clux/kube-rs/blob/master/examples/crd_derive_schema.rs))
/// - **customizing [certain kubebuilder like validation rules](https://github.com/clux/kube-rs/issues/129#issuecomment-749463718)** (tail the issue for state of affairs)
/// - **customizing [merge-strategies](https://kubernetes.io/docs/reference/using-api/server-side-apply/#merge-strategy)** (e.g. like in the [`crd_derive_schema` example](https://github.com/kube-rs/kube-rs/blob/master/examples/crd_derive_schema.rs))
/// - **customizing [certain kubebuilder like validation rules](https://github.com/kube-rs/kube-rs/issues/129#issuecomment-749463718)** (tail the issue for state of affairs)
/// - **embedding k8s-openapi types** within your structs (see [k8s-openapi#86](https://github.com/Arnavion/k8s-openapi/issues/86))
///
/// See [kubernetes openapi validation](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation) for the format of the OpenAPI v3 schemas.
///
/// If you have to override a lot, [you can opt-out of schema-generation entirely](https://github.com/clux/kube-rs/issues/355#issuecomment-751253657)
/// If you have to override a lot, [you can opt-out of schema-generation entirely](https://github.com/kube-rs/kube-rs/issues/355#issuecomment-751253657)
///
/// ## Debugging
/// Try `cargo-expand` to see your own macro expansion.
Expand Down
2 changes: 1 addition & 1 deletion kube-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = [
"clux <[email protected]>",
]
license = "Apache-2.0"
repository = "https://github.com/clux/kube-rs"
repository = "https://github.com/kube-rs/kube-rs"
keywords = ["kubernetes", "runtime", "reflector", "watcher", "controller"]
categories = ["web-programming::http-client"]
edition = "2018"
Expand Down
15 changes: 7 additions & 8 deletions kube-runtime/src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ where
let reconciler_span = info_span!("reconciling object", "object.ref" = %request.obj_ref, object.reason = %request.reason);
reconciler_span.in_scope(|| reconciler(obj, context.clone()))
.into_future()
.instrument(reconciler_span)
.instrument(reconciler_span.clone())
// Reconciler errors are OK from the applier's PoV, we need to apply the error policy
// to them separately
.map(|res| Ok((request.obj_ref, res)))
.map(|res| Ok((request.obj_ref, res, reconciler_span)))
.left_future()
},
None => future::err(
Expand All @@ -295,14 +295,14 @@ where
)
.on_complete(async { tracing::debug!("applier runner-merge terminated") })
// finally, for each completed reconcile call:
.and_then(move |(obj_ref, reconciler_result)| {
.and_then(move |(obj_ref, reconciler_result, reconciler_span)| {
let (ReconcilerAction { requeue_after }, requeue_reason) = match &reconciler_result {
Ok(action) =>
// do what user told us
(action.clone(), ReconcileReason::ReconcilerRequestedRetry),
Err(err) =>
// reconciler fn call failed
(error_policy(err, err_context.clone()), ReconcileReason::ErrorPolicyRequestedRetry),
(reconciler_span.in_scope(|| error_policy(err, err_context.clone())), ReconcileReason::ErrorPolicyRequestedRetry),
};
let mut scheduler_tx = scheduler_tx.clone();
async move {
Expand Down Expand Up @@ -486,12 +486,11 @@ where
/// To watch the full set of `Child` objects in the given `Api` scope, you can use [`ListParams::default`].
///
/// [`OwnerReference`]: k8s_openapi::apimachinery::pkg::apis::meta::v1::OwnerReference
pub fn owns<Child: Clone + Resource<DynamicType=()> + DeserializeOwned + Debug + Send + 'static>(
pub fn owns<Child: Clone + Resource<DynamicType = ()> + DeserializeOwned + Debug + Send + 'static>(
self,
api: Api<Child>,
lp: ListParams,
) -> Self
{
) -> Self {
self.owns_with(api, (), lp)
}

Expand Down Expand Up @@ -529,7 +528,7 @@ where
/// to watch - in the Api's configured scope - and run through the custom mapper.
/// To watch the full set of `Watched` objects in given the `Api` scope, you can use [`ListParams::default`].
pub fn watches<
Other: Clone + Resource<DynamicType=()> + DeserializeOwned + Debug + Send + 'static,
Other: Clone + Resource<DynamicType = ()> + DeserializeOwned + Debug + Send + 'static,
I: 'static + IntoIterator<Item = ObjectRef<K>>,
>(
self,
Expand Down
2 changes: 1 addition & 1 deletion kube/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [
"ynqa <[email protected]>",
]
license = "Apache-2.0"
repository = "https://github.com/clux/kube-rs"
repository = "https://github.com/kube-rs/kube-rs"
readme = "../README.md"
keywords = ["kubernetes", "client", "runtime", "reflector", "informer"]
categories = ["web-programming::http-client"]
Expand Down
2 changes: 1 addition & 1 deletion kube/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl Config {
}
}

// https://github.com/clux/kube-rs/issues/146#issuecomment-590924397
// https://github.com/kube-rs/kube-rs/issues/146#issuecomment-590924397
/// Default Timeout
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(295);

Expand Down
2 changes: 1 addition & 1 deletion kube/src/discovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl Discovery {
/// Ok(())
/// }
/// ```
/// See a bigger example in [examples/dynamic.api](https://github.com/clux/kube-rs/blob/master/examples/dynamic_api.rs)
/// See a bigger example in [examples/dynamic.api](https://github.com/kube-rs/kube-rs/blob/master/examples/dynamic_api.rs)
pub async fn run(mut self) -> Result<Self> {
self.groups.clear();
let api_groups = self.client.list_api_groups().await?;
Expand Down
6 changes: 3 additions & 3 deletions prerelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ set -euo pipefail
replace-docs() {
# Swap UNRELEASED header with a versioned and dated one, and remove compare url in it
sd "UNRELEASED" "${NEW_VERSION} / $(date +%Y-%m-%d)" CHANGELOG.md
sd " \* see https://github.com/clux/kube-rs/compare/.*...master\n" "" CHANGELOG.md
sd " \* see https://github.com/kube-rs/kube-rs/compare/.*...master\n" "" CHANGELOG.md
# Create a new UNRELEASED header, and add compare url to it
sd "<!-- next-header -->" "<!-- next-header -->\nUNRELEASED\n===================\n * see https://github.com/clux/kube-rs/compare/${NEW_VERSION}...master\n" CHANGELOG.md
sd "<!-- next-header -->" "<!-- next-header -->\nUNRELEASED\n===================\n * see https://github.com/kube-rs/kube-rs/compare/${NEW_VERSION}...master\n" CHANGELOG.md
# Replace all space-prefixed issue links with a dumb one to this repo
# This may link to an issue when it's a pull, but github redirects
# shellcheck disable=SC2016
sd ' \#(\d+)' ' [#$1](https://github.com/clux/kube-rs/issues/$1)' CHANGELOG.md
sd ' \#(\d+)' ' [#$1](https://github.com/kube-rs/kube-rs/issues/$1)' CHANGELOG.md
sed -i "s/${PREV_VERSION}/${NEW_VERSION}/g" kube-derive/README.md
sed -i "s/${PREV_VERSION}/${NEW_VERSION}/g" README.md
}
Expand Down
2 changes: 1 addition & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# integration tests

This is a working example of a kubernetes application `dapp`, that is deployed on CI during circle's `kind_k8s` and `kind_compile` job. See [this part of the .circleci/config](https://github.com/clux/kube-rs/blob/9837d60246a0528f8d810243fe544014d1e51dca/.circleci/config.yml#L32-L84).
This is a working example of a kubernetes application `dapp`, that is deployed on CI during circle's `kind_k8s` and `kind_compile` job. See [this part of the .circleci/config](https://github.com/kube-rs/kube-rs/blob/9837d60246a0528f8d810243fe544014d1e51dca/.circleci/config.yml#L32-L84).

## Behavior
The app currently only does what the `job_api` example does, but from within the cluster, so it needs the rbac permissions to `create` a `job` in `batch`.
Expand Down

0 comments on commit db5eed7

Please sign in to comment.