The Secret Tamil Book Pdf Download

2 views
Skip to first unread message

Josephina

unread,
Aug 4, 2024, 9:43:51 PM8/4/24
to roehimale
ASecret is an object that contains a small amount of sensitive data such asa password, a token, or a key. Such information might otherwise be put in aPod specification or in acontainer image. Using aSecret means that you don't need to include confidential data in yourapplication code.

Because Secrets can be created independently of the Pods that use them, thereis less risk of the Secret (and its data) being exposed during the workflow ofcreating, viewing, and editing Pods. Kubernetes, and applications that run inyour cluster, can also take additional precautions with Secrets, such as avoidingwriting sensitive data to nonvolatile storage.


Kubernetes Secrets are, by default, stored unencrypted in the API server's underlying data store(etcd). Anyone with API access can retrieve or modify a Secret, and so can anyone with access to etcd.Additionally, anyone who is authorized to create a Pod in a namespace can use that access to readany Secret in that namespace; this includes indirect access such as the ability to create aDeployment.


You can make your data "hidden" by defining a key that begins with a dot.This key represents a dotfile or "hidden" file. For example, when the following Secretis mounted into a volume, secret-volume, the volume will contain a single file,called .secret-file, and the dotfile-test-container will have this filepresent at the path /etc/secret-volume/.secret-file.


Consider a program that needs to handle HTTP requests, do some complex businesslogic, and then sign some messages with an HMAC. Because it has complexapplication logic, there might be an unnoticed remote file reading exploit inthe server, which could expose the private key to an attacker.


This could be divided into two processes in two containers: a frontend containerwhich handles user interaction and business logic, but which cannot see theprivate key; and a signer container that can see the private key, and respondsto simple signing requests from the frontend (for example, over localhost networking).


For example: implement (or deploy) an operatorthat fetches short-lived session tokens from an external service, and then creates Secrets basedon those short-lived session tokens. Pods running in your cluster can make use of the session tokens,and operator ensures they are valid. This separation means that you can run Pods that are unaware ofthe exact mechanisms for issuing and refreshing those session tokens.


When creating a Secret, you can specify its type using the type field ofthe Secretresource, or certain equivalent kubectl command line flags (if available).The Secret type is used to facilitate programmatic handling of the Secret data.


If you are defining a type of Secret that's for public use, follow the conventionand structure the Secret type to have your domain name before the name, separatedby a /. For example: cloud-hosting.example.net/cloud-api-credentials.


Opaque is the default Secret type if you don't explicitly specify a type ina Secret manifest. When you create a Secret using kubectl, you must use thegeneric subcommand to indicate an Opaque Secret type. For example, thefollowing command creates an empty Secret of type Opaque:


A kubernetes.io/service-account-token type of Secret is used to store atoken credential that identifies aServiceAccount. Thisis a legacy mechanism that provides long-lived ServiceAccount credentials toPods.


In Kubernetes v1.22 and later, the recommended approach is to obtain ashort-lived, automatically rotating ServiceAccount token by using theTokenRequestAPI instead. You can get these short-lived tokens using the following methods:


When using this Secret type, you need to ensure that thekubernetes.io/service-account.name annotation is set to an existingServiceAccount name. If you are creating both the ServiceAccount andthe Secret objects, you should create the ServiceAccount object first.


After the Secret is created, a Kubernetes controllerfills in some other fields such as the kubernetes.io/service-account.uid annotation, and thetoken key in the data field, which is populated with an authentication token.


See the ServiceAccountdocumentation for more information on how ServiceAccounts work.You can also check the automountServiceAccountToken field and theserviceAccountName field of thePodfor information on referencing ServiceAccount credentials from within Pods.


When you create Docker config Secrets using a manifest, the APIserver checks whether the expected key exists in the data field, andit verifies if the value provided can be parsed as a valid JSON. The APIserver doesn't validate if the JSON actually is a Docker config file.


The kubernetes.io/basic-auth type is provided for storing credentials neededfor basic authentication. When using this Secret type, the data field of theSecret must contain one of the following two keys:


The basic authentication Secret type is provided only for convenience.You can create an Opaque type for credentials used for basic authentication.However, using the defined and public Secret type (kubernetes.io/basic-auth) helps otherpeople to understand the purpose of your Secret, and sets a convention for what key namesto expect.


The builtin type kubernetes.io/ssh-auth is provided for storing data used inSSH authentication. When using this Secret type, you will have to specify assh-privatekey key-value pair in the data (or stringData) fieldas the SSH credential to use.


The SSH authentication Secret type is provided only for convenience.You can create an Opaque type for credentials used for SSH authentication.However, using the defined and public Secret type (kubernetes.io/ssh-auth) helps otherpeople to understand the purpose of your Secret, and sets a convention for what key namesto expect.The Kubernetes API verifies that the required keys are set for a Secret of this type.


One common use for TLS Secrets is to configure encryption in transit foran Ingress, but you can also use itwith other resources or directly in your workload.When using this type of Secret, the tls.key and the tls.crt key must be providedin the data (or stringData) field of the Secret configuration, although the APIserver doesn't actually validate the values for each key.


The TLS Secret type is provided only for convenience.You can create an Opaque type for credentials used for TLS authentication.However, using the defined and public Secret type (kubernetes.io/tls)helps ensure the consistency of Secret format in your project. The API serververifies if the required keys are set for a Secret of this type.


You can specify the data and/or the stringData field when creating aconfiguration file for a Secret. The data and the stringData fields are optional.The values for all keys in the data field have to be base64-encoded strings.If the conversion to base64 string is not desirable, you can choose to specifythe stringData field instead, which accepts arbitrary strings as values.


The keys of data and stringData must consist of alphanumeric characters,-, _ or .. All key-value pairs in the stringData field are internallymerged into the data field. If a key appears in both the data and thestringData field, the value specified in the stringData field takesprecedence.


Individual Secrets are limited to 1MiB in size. This is to discourage creationof very large Secrets that could exhaust the API server and kubelet memory.However, creation of many smaller Secrets could also exhaust memory. You canuse a resource quota to limit thenumber of Secrets (or other resources) in a namespace.


Depending on how you created the Secret, as well as how the Secret is used inyour Pods, updates to existing Secret objects are propagated automatically toPods that use the data. For more information, refer to Using Secrets as files from a Pod section.


Secrets can be mounted as data volumes or exposed asenvironment variablesto be used by a container in a Pod. Secrets can also be used by other parts of thesystem, without being directly exposed to the Pod. For example, Secrets can holdcredentials that other parts of the system should use to interact with externalsystems on your behalf.


If the Secret cannot be fetched (perhaps because it does not exist, ordue to a temporary lack of connection to the API server) the kubeletperiodically retries running that Pod. The kubelet also reports an Eventfor that Pod, including details of the problem fetching the Secret.


If you want to access data from a Secret in a Pod, one way to do that is tohave Kubernetes make the value of that Secret be available as a file insidethe filesystem of one or more of the Pod's containers.


The kubelet keeps a cache of the current keys and values for the Secrets that are used involumes for pods on that node.You can configure the way that the kubelet detects changes from the cached values. TheconfigMapAndSecretChangeDetectionStrategy field in thekubelet configuration controlswhich strategy the kubelet uses. The default strategy is Watch.


Updates to Secrets can be either propagated by an API watch mechanism (the default), based ona cache with a defined time-to-live, or polled from the cluster API server on each kubeletsynchronisation loop.


As a result, the total delay from the moment when the Secret is updated to the momentwhen new keys are projected to the Pod can be as long as the kubelet sync period + cachepropagation delay, where the cache propagation delay depends on the chosen cache type(following the same order listed in the previous paragraph, these are:watch propagation delay, the configured cache TTL, or zero for direct polling).


It's important to note that the range of characters allowed for environment variablenames in pods is restricted.If any keys do not meet the rules, those keys are not made available to your container, thoughthe Pod is allowed to start.


If you want to fetch container images from a private repository, you need a way forthe kubelet on each node to authenticate to that repository. You can configureimage pull Secrets to make this possible. These Secrets are configured at the Podlevel.

3a8082e126
Reply all
Reply to author
Forward
0 new messages