I'm very new to kubernetes .What is meant for kind: Deployment?. What are the different kind. Is there any document available for this?
kind represents the type of Kubernetes objects to be created while using the yaml file.
kind: Deployment represents the Kubernetes Deployment object.
You can use the following command to view different supported objects:
kubectl api-resources
You can also review the API reference for detailed overview regarding the Kubernetes objects.
Related
Is it possible to create a Kubernetes service and pod in different namespaces, for example, having myweb-svc pointing to the actual running myweb-pod, while myweb-svc and myweb-pod are in different namespaces?
YAML manifest to create both the pod and the service in their respective namespaces. You need to specify the ‘namespace’ field in the ‘metadata’ section of both the ‘pod’ and ‘service’ objects to specify the namespace in which they should be created.
Also, if you want to point your Service to a Service in a different namespace or on another cluster you can use service without a pod selector.
Refer to this link on Understanding kubernetes Object for more information.
Kubernetes API objects that are connected together at the API layer generally need to be in the same namespace. So a Service can only connect to Pods in its own namespace; if a Pod references a ConfigMap or a Secret or a PersistentVolumeClaim, those need to be in the same namespace as well.
What is the difference between $kubectl create deploy and $kubectl create deployment? Google Cloud Fundamental's Lab is using kubectl create deploy command, but in the Kubernetes documentation/Interactive Tutorial (https://kubernetes.io/docs/tutorials/kubernetes-basics/deploy-app/deploy-interactive/), it is using the command kubectl create deployment. So just wanted to ask this group, which one is the correct/latest?
The kubectl create deploy and kubectl create deployment commands both create a deployment in Kubernetes. The only difference is that the kubectl create deploy command is a shorthand version of the kubectl create deployment command. The kubectl create deployment command is the more verbose version and provides more options for creating a deployment.
The two commands are effectively interchangeable and both will create a Kubernetes deployment.Ultimately, it is up to the user to decide which syntax to use, as long as the deployment is created successfully.
As #gohmc and #fcmam5 said, The kubectl api-resources command prints a list of all of the available API resources in the Kubernetes cluster. The list includes the resource name, the kind of resource it is, and the API version it belongs to. Here is an example of the output of the command:
NAME KIND APIVERSION
bindings Binding v1
configmaps ConfigMap v1
endpoints Endpoints v1
events Event v1beta1
limitranges LimitRange v1
namespaces Namespace v1
pods Pod v1
replicationcontrollers ReplicationController v1
resourcequotas ResourceQuota v1
secrets Secret v1
services Service v1
As per this SO, you can also kubectl api-resources -o wide shows all the resources, verbs and associated API-group.
For more information refer to this kubernetes cheatsheet
They meant the same. You can find the SHORTNAMES for K8s resource with kubectl api-resources.
These deploy is a short-name for deployment, same as po for pod, you can see the full list of commands and their shortened versions with:
kubectl api-resources
I'm trying to set a grace shutdown period for my pods. I found out you can add a field called terminationGracePeriodSeconds to the helm charts to set the period. I then looked for example and crossed upon these:
https://cloud.google.com/blog/products/containers-kubernetes/kubernetes-best-practices-terminating-with-grace
In the above link they define the value in a kind: pod template.
https://pracucci.com/graceful-shutdown-of-kubernetes-pods.html
In the above link they define the value in a kind: deployment template.
Is there a difference between the 2 kinds in regard to where I define this value?
Is there a difference between the 2 kinds in regard to where I define this value?
A Deployment has a field template: and that is actually a PodTemplate (most structure of a Pod) that includes the terminationGracePeriodSeconds property.
A good way to check documentations for fields is to use kubectl explain.
E.g.
kubectl explain Deployment.spec.template.spec
and
kubectl explain Pod.spec
I am building an application which should execute tasks in a separate container/pods.
this application would be running in a specific namespace the new pods must be created in the same namespace as well.
I understand we can similar via custom CRD and Operators, but I found it is overly complicated and we need Golang knowledge for the same.
Is there any way this could be achived without having to learn Operators and GoLang?
I am ok to use kubctl or api within my container and wanted to connect the host and to the same namespace.
Yes, this is certainly possible using a ServiceAccount and then connecting to the API from within the Pod.
First, create a ServiceAccount in your namespace using
kubectl create serviceaccount my-service-account
For your newly created ServiceAccount, give it the permissions you want using Roles and RoleBindings. The subject would be something like this:
subjects:
- kind: ServiceAccount
name: my-service-account
namespace: my-namespace
Then, add the ServiceAccount to the Pod from where you want to create other Pods from (see documentation). Credentials are automatically mounted inside the Pod using automountServiceAccountToken.
Now from inside the Pod you can either use kubectl or call the API using the credentials inside the Pod. There are libraries for a lot of programming languages to talk to Kubernetes, use those.
I am working with Istio. There are certain annotations that we add to our kubernetes namespace. One out of these namespace annotations also needs to be applied to the pods that are created with sidecar-enabled=true label. For this purpose, I looked at using the Istio sidecar injector webhook, but I am not able to find the reference to namespace's annotations.
Is there a way to do this?
You can find all need namespaces annotations using below command in Annotations: section.
kubectl describe namespaces
EDIT:
Your initial question is not clear. As far as I understand your question and additional clarification - you want to get annotations that are applied to a namespace from a configMap.
Official Istio Sidecar Injection Documentation says that
Manual and automatic injection both use the configuration from the
istio-sidecar-injector and istio ConfigMaps in the istio-system
namespace.
Based on this fact you can dump the configMap in the Istio cluster you are interested in by next command:
$ kubectl describe configmap --namespace=istio-system istio-sidecar-injector
This will show you references for pod annotations, global values, etc.
Example:
[[ annotation .ObjectMeta `traffic.sidecar.istio.io/includeOutboundIPRanges` "*" ]]
The above queries traffic.sidecar.istio.io/includeOutboundIPRanges annotation on the pod, and defaults to "*" if it's not present.