This repository has been archived by the owner on Feb 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 532
fleet functionality K8s does not have #945
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9a01e9e
fleet functionality K8s does not have initial
pop fdf583e
spelling/add ideas
3ec7b63
Rename depricated-functionality.md to deprecated-functionality.md
1bd4c8f
Kubernetes: Added updates to depricated fleet docs
pop 8f9d058
k8s: Feedback to depricated functionality
pop 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 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,65 @@ | ||
# Deprecated functionality | ||
|
||
While fleet and Kubernetes are largely similar in functionality, some specific fleet features do not have direct equivalents in Kubernetes.Fortunately, workarounds exist for almost every use-case. Several of these features and workarounds are outlined below. | ||
|
||
## Container Dependencies | ||
|
||
Fleet uses systemd service dependencies to outline a *limited* dependency graph. When units are co-located then containers may be specified to start in a specific order; only beginning a service *after* others it depends on have begun. This is not really a fleet feature but rather a systemd feature; it is limited by the design and feature-set of systemd | ||
|
||
While this has been [discussed at length in the Kubernetes community][pod-deps-discussion] it has not been implemented in Kubernetes as of early 2017. There are two workarounds for this in Kubernetes: | ||
|
||
1. Grouping related containers in a Pod. | ||
2. [Init containers][k8s-init-containers] | ||
|
||
### Grouping containers in Pods | ||
|
||
This is the most straight forward to approach the problem. Pods specs can contain multiple containers. By grouping related containers in one Pod then Kubernetes will co-locate them and monitor if all of the containers are functioning correctly. | ||
|
||
[comment]: # (TODO: Include an example?) | ||
|
||
### Init containers | ||
|
||
[Init containers][k8s-init-containers] are containers run before a Pod starts up. They can be used to manage assets, wait for services, and perform general pre-pod setup. A pod is not scheduled until it's init-containers complete. | ||
|
||
[comment]: # (TODO: Include an example?) | ||
|
||
## Graceful Exit Command (ExecStop) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ExecStop in fleet is somewhat broken, tbh: coreos/fleet#1000. I think this also warrants calling out. |
||
|
||
Fleet uses the systemd option [ExecStop][fleet-execstop] to instruct systemd how to stop a service gracefully. **Note** that this feature has worked in fleet in the past, but [has proven to be problematic in practice][fleet-exec-issue]. | ||
|
||
While this functionality does not exist in Kubernetes, the `ExecPreStop` does have an analogue in the Kubernetes world: `lifecycle.preStop`! | ||
|
||
A Pod [lifecycle.preStop][lifecycle-hooks] directive specifies a command run **before** Kubernetes terminates an application with `SIGTERM`. This achieves a similar result of gracefully stopping a container. | ||
|
||
Here is an example of using `lifecycle.preStop`, inspired by the Kubernetes docs: | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: web-server | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx | ||
ports: | ||
- containerPort: 80 | ||
lifecycle: | ||
preStop: | ||
exec: | ||
# SIGTERM triggers a quick exit; gracefully terminate instead | ||
command: ["/usr/sbin/nginx","-s","quit"] | ||
``` | ||
|
||
[comment]: # (TODO: Think of a better example for preStop. Need a clearer demo.) | ||
|
||
More information can be found at the [Kubernetes Pods user guide][prestop] | ||
|
||
**Note:** The `preStop` directive is not a replacement for ExecStop. After a grace-period the container will still be killed via `SIGTERM`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this isn't totally true. You can set the graceful shutdown time to nearly forever terminationGracePeriodSeconds https://kubernetes.io/docs/api-reference/v1/definitions/#_v1_pod |
||
|
||
[fleet-exec-issue]: https://github.com/coreos/fleet/issues/1000 | ||
[fleet-execstop]: https://coreos.com/fleet/docs/latest/launching-containers-fleet.html#run-a-container-in-the-cluster | ||
[k8s-init-containers]: http://kubernetes.io/docs/user-guide/pods/init-container/ | ||
[lifecycle-hooks]: http://kubernetes.io/docs/user-guide/production-pods/#lifecycle-hooks-and-termination-notice | ||
[pod-deps-discussion]: https://github.com/kubernetes/kubernetes/issues/2385 | ||
[prestop]: http://kubernetes.io/docs/user-guide/pods/#termination-of-pods |
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.
I think we should essentially say most use cases can be solved by crash loops on a pod and init containers. I don't think pod deps will ever be implemented.