2 min read
There are several strategies available for updating a deployment on Kubernetes, by default it will trigger a rolling update: It will deploy the new version before tearing down the old one so there's no downtime associated to it.
Let's see how we can see this process by applying an update to a deployment:
$ kubectl apply -f deployment.yaml
17/05/2021
Read more...2 min read
To change a container's image we can:
Let's check how to use kubectl set image
14/05/2021
Read more...2 min read
When we want to access services that run inside a kubernetes cluster that are not supposed to be normally accessed we can temporally run kubectl port-forward to forward traffic to our workstation. To be able to use it, the node must have socat installed.
13/05/2021
Read more...3 min read
With terraform taint we are telling terraform that a particular object has become degraded so it will propose to replace it in the next plan. This command is going to be deprecated on terraform v1.0 since now we have the -replace flag on the apply command
$ terraform taint kubernetes_namespace.pet2cattle_namespace
Acquiring state lock. This may take a few moments...
Resource instance kubernetes_namespace.pet2cattle_namespace has been marked as tainted.
Releasing state lock. This may take a few moments...
12/05/2021
Read more...2 min read
The /etc/hosts file is a Kubernetes-managed file so we cannot add entries freely to it. If we want to add entries to it we will have to use the hostAliases field in the Pod's spec.
$ kubectl exec -it demo-pod -- cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
10.103.198.74 demo-pod
11/05/2021
Read more...3 min read
On a AWS EKS cluster, at the time of this writing, by default you cannot resize volumes provisioned with the default gp2 StorageClass. This is because on the default StorageClass the allowVolumeExpansion is set to false, preventing the volume expansion:
$ kubectl get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
gp2 (default) kubernetes.io/aws-ebs Delete WaitForFirstConsumer false 78d
10/05/2021
Read more...1 min read
To be able to get a list of resources managed by terraform we can use terraform state list for listing all the resources on the terraform state:
07/05/2021
Read more...2 min read
One of the nicest functions terraform has is terraform fmt: Just as go fmt would do with Go code, it will rewrite Terraform configuration files (.tf and .tfvars files) to a canonical format and style. This will improve it's readability, helping making the code more consistent.
06/05/2021
Read more...2 min read
On Kubernetes we can configure using the Pod manifest under which conditions we want to query the container registry to pull images by using the imagePullPolicy setting. We can configure the it on several objects like Deployment, StatefulSet, Pod, Job... In fact, we can set it on any object that includes a Pod template
apiVersion: v1
kind: Pod
metadata:
name: test-pod
namespace: demo
spec:
containers:
- image: alpine
imagePullPolicy: IfNotPresent
(...)
05/05/2021
Read more...3 min read
If we have some of the infrastructure that were created manually we can still import it into the terraform state. This ensures you can have a smooth transition from manually created resources to Infrastructure as Code
To do so we will be using then terraform import command:
$ terraform import
The import command expects two arguments.
Usage: terraform import [options] ADDR ID
(...)
04/05/2021
Read more...