Java/k8/Docker/Python Flashcards
jar, war, ear files?
jar
java archive file. This holds all of the java classes, resources, dependencies
war
web archive file. This holds all the files needed for a web application. Including resources, html, css, javascript, jar files, xml, everything needed to run the web app. It is portable too
ear
ear files are war files for an enterprise application. It is a collection of jars, wars, files, resources, sometimes multiple jars and wars too.
Spring
perform validation on the output of an object created from the application.properties file
Use javax validation, an application listener that launches after spring has loaded, and autowire the @Validator component, call validator.validate and it will return a set of violations. If there are any violations, there was an error.
upper bound generics, lower bound generics
TLDR: producer extends, consumer super. If you are making an object that will produce objects (a list, and then you iterate through it and do things with each item) do extends thing>
If you want the list to consume objects and store them, you need to have Collections super thing> bc extends doesn’t work bc you can’t specify each type is of type thing unless it is super.
Suppose you have a method that takes as its parameter a collection of things, but you want it to be more flexible than just accepting a Collection.
Case 1: You want to go through the collection and do things with each item.
Then the list is a producer, so you should use a Collection extends Thing>.
The reasoning is that a Collection extends Thing> could hold any subtype of Thing, and thus each element will behave as a Thing when you perform your operation. (You actually cannot add anything (except null) to a Collection extends Thing>, because you cannot know at runtime which specific subtype of Thing the collection holds.)
Case 2: You want to add things to the collection.
Then the list is a consumer, so you should use a Collection super Thing>.
The reasoning here is that unlike Collection extends Thing>, Collection super Thing> can always hold a Thing no matter what the actual parameterized type is. Here you don’t care what is already in the list as long as it will allow a Thing to be added; this is what ? super Thing guarantees.
Differences between services/deployments/replicas/pods
Pods are the base deployment for k8s.
Replica sets replicate the pods with 1 command, so you can spawn many at once
Deployments help keep track of a set of pods. It is a config file that lists everything necessary about certain deployment spec you would want, including services, container versions, ingress, ect
Services act as “load balancers” to deployments. If you match the labels up, the services handles traffic to all of the pods in the deployment. It exposes a port on the service which exposes a port on each deployment pod, which exposes a port on the container it is using
https: //matthewpalmer.net/kubernetes-app-developer/articles/service-kubernetes-example-tutorial.html
https: //www.youtube.com/watch?v=cK1iSwfF4dM