-->

Thursday, March 30, 2023

[Solved] creating EC2 Subnet: InvalidParameterValue: Value (us-east-2b) for parameter availabilityZone is invalid. Subnets can currently only be created in the following availability zones: us-east-1a, us-east-1b, us-east-1c, us-east-1d, us-east-1e, us-east-1f.

 Issue:-

While creating the multiple region vpc through the terraform getting the error during terraform apply when it tries to create the subnets in 2nd vpc.


Error:-

 module.vpc2.aws_subnet.public[0]: Creating...  
 ╷  
 │ Error: creating EC2 Subnet: InvalidParameterValue: Value (us-west-2b) for parameter availabilityZone is invalid. Subnets can currently only be created in the following availability zones: us-east-1a, us-east-1b, us-east-1c, us-east-1d, us-east-1e, us-east-1f.  
 │      status code: 400, request id: 79a19b0b-93d1-4a78-9c0c-124e429c78de  
 │   
 │  with module.vpc2.aws_subnet.public[1],  
 │  on .terraform/modules/vpc2/main.tf line 359, in resource "aws_subnet" "public":  
 │ 359: resource "aws_subnet" "public" {  

 

Cause:-

Even though i mentioned the providers still the terraform was trying to create the us-west-2b subnet in the wrong region i.e. us-east-1 and it was not able to find those subnets and thats why aws is throughing the error that only us-east-1a, us-east-1b, us-east-1c, us-east-1d, us-east-1e, us-east-1f subnets are available to create the subnets.

Saturday, March 25, 2023

[Solved] forbidden: User "system:serviceaccount:default:app-name" cannot delete resource "pods" in API group "" in the namespace "default""

Issue:

When trying to delete a Kubernetes pod via the Go-client library, an error is encountered: "pods "app-name" is forbidden: User "system:serviceaccount:default:app-name" cannot delete resource "pods" in API group "" in the namespace "default""


Code:

The following code is used to delete the pod via the Go-client library:

 err := ks.clientset.CoreV1().Pods(kubeData.PodNamespace).Delete(context.Background(), kubeData.PodName, metav1.DeleteOptions{})  
 if err != nil {  
 log.Fatal(err)  
 }  

The serviceaccount file that i was passing was

 {{- $sa := print .Release.Name "-" .Values.serviceAccount -}}  
 ---  
 apiVersion: v1  
 kind: ServiceAccount  
 metadata:  
  name: {{ $sa }}  
  namespace: {{ .Release.Namespace }}  
 ---  
 apiVersion: rbac.authorization.k8s.io/v1  
 kind: Role  
 metadata:  
  name: {{ $sa }}  
 rules:  
  - apiGroups: ["apps"]  
   verbs: ["patch", "get", "list"]  
   resources:  
    - deployments  
 ---  
 apiVersion: rbac.authorization.k8s.io/v1  
 kind: Role  
 metadata:  
  name: {{ $sa }}  
 rules:  
  - apiGroups: ["apps"]  
   verbs: ["delete", "get", "list"]  
   resources:  
    - pods  
 ---  
 apiVersion: rbac.authorization.k8s.io/v1  
 kind: RoleBinding  
 metadata:  
  name: {{ $sa }}  
 roleRef:  
  apiGroup: rbac.authorization.k8s.io  
  kind: Role  
  name: {{ $sa }}  
 subjects:  
  - kind: ServiceAccount  
   name: {{ $sa }}  

[Solved] MountVolume.SetUp failed for volume

 Kubernetes Persistent Volume Claims (PVC) are used to abstract the underlying storage infrastructure, allowing developers to mount storage to a pod without knowing the details of the storage. However, sometimes the PVC may fail to mount, causing the applications to fail. In this article, we will discuss the steps to troubleshoot and resolve such issues.


Issue:

When trying to mount a PVC in a Kubernetes pod, the mount fails with the following error:

"MountVolume.SetUp failed for volume [volume name] : failed to fetch token: cannot get auth token"


Error:

The error message "MountVolume.SetUp failed for volume [volume name] : failed to fetch token: cannot get auth token" indicates that the pod was not able to authenticate to the storage provider and obtain the required credentials to mount the volume.