Posts

Showing posts from May, 2021

Statefule Sets and Config Map

 ConfigMap is an API object that allows you to store non-confidential data as key value pairs. It allows to decouple environment specific information from your container images making them more portable. Pods can consume config maps as environment variables, command line arguments or config files in volumes. Stateful set is workload API object used to manage stateful applications. 

Difference between docker cmd and docker entrypoint instructions and RUN COPY and ADD

 Docker cmd helps define the default command and or parameters. The parameters of a CMD instruction can be over-ridden. If a dockerfile has several CMD only the last will be run. Docker entrypoint helps to define the container as an executable. RUN is an instruction that runs at the build time of the container. CMD runs when the container is starting COPY command copies files from local directory to a directory in the container ADD apart from the COPY functionality also allows to copy from URL or untars a tar file from source into the destination in the container Shell Form -> Instruction <command> Exec form -> Instruction ["executable", "param1", "param2"]

EKS nuggets: Unauthorized error via kubectl

 EKS is the managed kubernetes service offering from AWS. After you have provisioned an EKS cluster you can access it via the kubectl utility. However, the kubectl utility requires you to have kubeconfig available in your home directory for it to be able to access the EKS cluster kubeApiServer. At time while running kubectl commands you might get error as below:- error: You must be logged in to the server (Unauthorized) This would indicate that the user with which you are logged into the AWS CLI is not the one who has provisioned the cluster. AWS adds the user who has provisioned the cluster as a cluster admin in the EKS cluster RBAC. To download EKS kubeconfig file you can run aws cli command as below:- aws eks --region ap-south-1 update-kubeconfig --name <clustername>

Terraform Nuggets: Issues with installing terraform providers in Windows 10 environments

 If running terraform version > = 0.14 in windows 10 environments at times you might face issues wherein while performing terraform init you face errors indicating that the installation of some of the providers fail. The error log would say that provider was not found at the specified path. Something like below:- Initializing provider plugins… Finding gavinbunney/kubectl versions matching “1.9.1”… Finding hashicorp/aws versions matching “~> 3.0”… Finding hashicorp/kubernetes versions matching “~> 1.11”… Installing gavinbunney/kubectl v1.9.1… Installing hashicorp/aws v3.21.0… Installed hashicorp/aws v3.21.0 (signed by HashiCorp) Installing hashicorp/kubernetes v1.13.3… Error: Failed to install provider Error while installing gavinbunney/kubectl v1.9.1: open .terraform\providers\ registry.terraform.io \gavinbunney\kubectl\1.9.1\windows_amd64\terraform-provider-kubectl_v1.9.1.exe: The system cannot find the path specified. Now although the cause of this error is not known yet...

Terraform Nuggets: What is terraform init

 Terraform init initializes your working directory containing the terraform configuration files. This is the first command to be run. It would load all the modules referenced in your configuration files and load all the provders referenced in your configuration files. During init the configuration is searched for module blocks, and the source code for the reference modules is retrieved from the locations given in their source arguments.  Most terraform providers are published separately from terraform as plugins. During init terraform searches the configuration for both direct and indirect references to providers and attempts to install the plugins for those providers. After successful installation terraform writes details about the selected providers in the dependency lock file. You should commit this file in the version control system to make sure that when the next time terraform init is run terraform will select exactly the same provider versions. Use -upgrade option if yo...

Terraform Nuggets: Disallow deletion of terraform resource

 We might get into trouble if we run terraform destroy over a stack which contains a critical resource which might be getting used by some other stack. To avoid such situations to prevent deletion of critical resources managed via terraform we can use a lifecycle block in the resource definition in terraform with prevent_destroy attribute set to true as below:-  resource "digitalocean_droplet" "db" {     lifecycle {             prevent_destroy = true     } } The Other arguments that can be used with lifecycle block are:-  1. create_before_destroy = by default in case of resources which cannot be updated in place, terraform first destroys the old resource and then creates a new one. However with this argument we can override the default behavior to create the new resource first before destroying the old one. 2. ignore_changes- By default, Terraform detects any difference in the current settings of a real infrastructure obje...