Giter Site home page Giter Site logo

k8spatterns / examples Goto Github PK

View Code? Open in Web Editor NEW
964.0 964.0 259.0 710 KB

Examples for "Kubernetes Patterns - Reusable Elements for Designing Cloud Native Applications", Second Edition

Home Page: https://k8spatterns.io

License: Other

Shell 58.61% Java 7.61% Dockerfile 22.18% Perl 4.84% JavaScript 6.75%

examples's People

Contributors

0x2b3bfa0 avatar bibryam avatar dependabot[bot] avatar dwdraju avatar imrehg avatar jan-kolarik avatar klintrup avatar lausser avatar nanjj avatar nerohin avatar openm avatar rhuss avatar sto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

examples's Issues

Create PDF document with all instructions.

Add a kubernets-patterns-examples.adoc top-level document which includes the instructions from each pattern.
Also create a CircleCI job for creating the PDF (and maybe other formats). This PDF should be committed, too.

Problems running PredictableDemands on Macbook Pro M2

I ran into a number of issues getting the foundational/PredictableDemands working.

  1. The random-generator application didn't work with the Mac architecture. I had to perform a multi-architecture build with buildx and then host the image in my own DockerHub account, which meant that I then had to update all of the images in the yml files to refer to my image.

This is what worked for me though there are probably other ways to solve this. You may need to support other architectures.

docker buildx create --use
docker buildx build --platform linux/amd64,linux/arm64 --push -t /random-generator:1.0 .

  1. On the Mac I could not use hostPaths that start at the root as Mac now has the root path as read-only. So I had to create a separate host path and then change the hostPath in yml files from /example, /logs, etc. to my hostpath.

  2. The generator application was returning a 500 server error with both pod.yml and deployment.yml. After some research I added the following spec above the app spec in deployment.yml and then it started to work. I think that it started working as a side effect as I was unable to properly debug the issue. Root cause is still a mystery to me.

spec:
containers:

  • command:
    • "tail"
    • "-f"
    • "/dev/null"

/opt/random-generator-ready not there

Hi, the published images don't have the /opt/random-generator-ready file causing some of the labs to behave odd.

I built my own images and the file is there.

Errata: Pod eviction on the Kubelet

Page 19, section on "Best-Effort"

It is not necessarily true that best-effort pods are evicted before other classes, i.e. burstable. The memory pressure rank (and eviction) logic has changed since v1.9: https://github.com/kubernetes/kubernetes/blob/da31c50da191ae1c055069b936d9e549741e3e8a/pkg/kubelet/eviction/helpers.go#L667

Pods with high resource consumption above requests will be evicted first, which not necessarily implies they're best-effort. E.g. a burstable pod with low requests but high mem usage will be evicted first: https://github.com/kubernetes/kubernetes/blob/da31c50da191ae1c055069b936d9e549741e3e8a/pkg/kubelet/eviction/helpers.go#L524

Note from the Author or Editor:
Thanks for the hint! I'm not 100% sure, whether the statement that 'best-effort' QoS container (i.e. those with no request limits) are not also considered to be evicted first, as according to https://github.com/kubernetes/kubernetes/blob/7b8c9acc09d51a8f6018eafc49490102ae7cb0c4/pkg/kubelet/eviction/helpers.go#L583 every current memory value is higher than the initValue (== 0 bytes).

That said, I'm not super intimidated with the K8s source, so not sure what the decision criteria are when there are multiple pods exceeding their resources.

Is it is like that the pod which exceed requests the most are evicted first? In that case, wouldn't a request value of 0 be a high-probability candidate for this criteria? Of course, that depends on the absolute values, too (e.g. having a request of 1 MB and limits 2 GB, and having an actual value of 1 GB put higher memory pressure on it as a best-effort Pod with the actual usage of 100 MB).

Do you think it's a valid simplification to still say the best-effort Pods are the one which is most likely killed the first? (or *with a high probability *)?

The purpose of this QoS categorization in the context of the book is to give the user a rough guideline of what to chose without knowing the super gory details. Here our intention was also to highly recommend to introduce limits in any case.

I totally agree though, that we should not use a normative statement like "always killed first".

Sorry for being nitpicky here :)

IIU the code base correctly, this is what happens:

// rankMemoryPressure orders the input pods for eviction in response to memory pressure.
// It ranks by whether or not the pod's usage exceeds its requests, then by priority, and
// finally by memory usage above requests.
func rankMemoryPressure(pods []*v1.Pod, stats statsFunc) {
	orderedBy(exceedMemoryRequests(stats), priority, memory(stats)).Sort(pods)
}

https://github.com/kubernetes/kubernetes/blob/f780ac028b444ed15d03de755c12fcf84c783286/pkg/kubelet/eviction/helpers.go#L667

Is it is like that the pod which exceed requests the most are evicted first? In that case, wouldn't a request value of 0 be a high-probability candidate for this criteria? Of course, that depends on the absolute values, too (e.g. having a request of 1 MB and limits 2 GB, and having an actual value of 1 GB put higher memory pressure on it as a best-effort Pod with the actual usage of 100 MB).

Right, it depends and thus a burstable pod with the same priority as a best-effort pod, but higher mem usage ratio above requests, would be evicted first.

Do you think it's a valid simplification to still say the best-effort Pods are the one which is most likely killed the first? (or *with a high probability *)?

Yes. this strikes a good balance without misleading the reader.

Same goes for this discussion on page 21:

Related to my previous comment on QoS and eviction, the Kubelet eviction logic has changed from QoS only to more complex since v1.9:

  1. usage > requests
  2. priority
  3. mem usage compared to requests

https://github.com/kubernetes/kubernetes/blob/da31c50da191ae1c055069b936d9e549741e3e8a/pkg/kubelet/eviction/helpers.go#L667

Note from the Author or Editor:
Confirmed that eviction policy is more complicated than QoS. Having requests set to "0" sets condition 1) for sure to 0, and for 3) the delta is potentially also much larger (for the same image)
We definitely should expand on this section and e.g. mention also that priority has a critical influence, i.e. to decided between two pods, both exceeding their requests (which is always the case for a pod with requests == 0, i.e. "Best Effort" QoS pods).

Errata: Distinct between node capacity and node allocatable

This is a copy over from the errata page to allow for better discussions:

Printed edition, Page 19 1st paragraph:

Speaking of "capacity" in the paragraph, it might be worth pointing out that this is allocatable capacity on the node, not node_capacity. Also a hint that InitContainers contribute to resource requirements (and thus scheduling) would be nice.

Note from the Author or Editor:
Hi Michael,

thanks a lot for your feedback. I'm not 100% sure what you mean with node_capacity in "this is allocatable capacity on the node, not node_capacity." Do you refer to a specific resource field ?

I agree, that your comment that init containers resource requirements should be mentioned here. We have a detailed explanation of resource requirements for init-containers in the"Init Container" pattern (i.e. the top paragraph on p. 127), but we should mention that here for sure, too.

... roland

+1 on the InitContainer.

Regarding node allocatable vs node capacity: minor detail, but worth mentioning I think (correctness and clarity). For scheduling and placement, not the node's capacity but allocatable resources are used -> https://kubernetes.io/docs/tasks/administer-cluster/reserve-compute-resources/#node-allocatable

Errata: At-most-once guarantees for StatefulSets

Page 95 in the printed book, last paragraph:

"When a node fails, it schedules new Pods on a different node unless Kubernetes can confirm that the Pods (and maybe the whole node) are shut down."

I think, corresponding with the "at most once" guarantee of stateful sets described in the chapter, this should read:

"When a node fails, it does not schedule new Pods on a different node unless Kubernetes can confirm that the Pods (and maybe the whole node) are shut down."

Health Probe: http://localhost:8080/toogle-live endpoint does not work

$ curl -s http://localhost:8080/toogle-live
Handling connection for 8080
{"timestamp":"2023-01-12T11:57:58.043+0000","status":404,"error":"Not Found","message":"No message available","path":"/toogle-live"}

same isse for toogle-ready:

$ curl http://localhost:8080/toogle-ready
{"timestamp":"2023-01-12T12:03:56.413+0000","status":404,"error":"Not Found","message":"No message available","path":"/toogle-ready"}

Write install and running instructions

For some patterns, the instructions for how to run the examples are missing

  • Daemon Service
  • Singleton Service
  • Service Discovery
  • Init Container
  • Ambassador
  • Adapter
  • Configuration Resource
  • Stateful Service
  • Elatic Scale

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.