How Do You Create a .kube/config File with a “aws eks” Command?

One of the following apply:

Problem scenario #1
You are using EKS and you have no config file in the .kube directory. You want to run some kubectl commands.

Problem scenario #2
You are using EKS and run a kubectl command, but you get this error: “The connection to the server localhost:8080 was refused – did you specify the right host or port?”

Solution
Run a command like this (but replace “us-west-1” with your region and replace “foobar” with the cluster_name):

aws eks –region us-west-1 update-kubeconfig –name foobar

How Do You Troubleshoot the Error ‘”/usr/share/collectd/types.db” no such file or directory’?

Problem scenario
You are running an aws ssm command. You receive a message about an error when parsing amazon-cloudwatch-agent.toml that also says ‘”/usr/share/collectd/types.db” no such file or directory’. What do you do?

Solution
Install collectd. If you are using a RedHat derivative of Linux (e.g., Fedora or CentOS), run this: sudo yum -y install collectd

How Do You Get Presto to Start when Errors about Presto requiring an Oracle or OpenJDK JVM?

Problem scenario
Presto will not run because of an error about the JVM.

You get a message like this:
“Java version has an unknown format: 15” (from “C” below)
“Presto requires an Oracle or OpenJDK JVM (found Ubuntu)” (associated with the Java version shown in B or D below)
“Presto requires an Oracle or OpenJDK JVM (found Private Build)” (associated with the Java version in E below)
“Presto requires an Oracle or OpenJDK JVM (found IcedTea)” (associated with the Java version shown in F below)

Solution
For detailed background information,

How Do You Create Nodes for EKS That Are Accessible to Log in?

Problem scenario
You want to create EC-2 instances (nodes) for Kubernetes in AWS using EKS. You want to be able to connect to them or log into them for the sake of troubleshooting. You want to configure the Kubernetes nodes to use a .pem or .ppk file for SSHing into them. You analyzed the create node group documentation on the internet, but found a vague reference to a –remote-access flag and a ec2Sshkey pointing to a string.

How Do You Know the Syntax of the JSON for the –policy-document Flag for Adding Policies to a Role in AWS?

One of the following scenarios apply:

Problem scenario #1
You want to run a command like this:
aws iam put-role-policy –role-name contintdelete-role –policy-name DELETEPOLICY –policy-document file://adminPolicy.json

But you do not know the syntax of the adminPolicy.json.

Problem scenario #2
You are trying to use the –policy-document flag with the command “aws iam put-role-policy”. But you get this error:

An error occurred (MalformedPolicyDocument) when calling the PutRolePolicy operation: Syntax errors in policy.

How Do You Troubleshoot the Python Error “NameError: name ” is not defined”?

Problem scenario
You are trying to run a Python program with a class. You get this message:

File “foobar.py”, line 11, in
class Building(param1, param2):
NameError: name ‘param1’ is not defined

What should you do?

Solution
Use the word “object” instead of one or more parameters that you are passing in the parentheses () of the class.

How Do You Use Ansible to Have Retrievable Double Quotes ‘”‘ in a Variable?

Problem scenario
You are using Ansible, and you want a playbook to have a variable with double quotes. The double quotes are disappearing from your echo var1.stdout[:] invocations. How do you get shell/bash commands to have double quotes?

Solution
Rather than “echo” a string with double quotes, use a variable assignment. Do not use this: echo “a \”long string\” for a \”test\” “

Use something like this: coolstring=”a \”long string\” for a \”test\” ” &&

How Do You Troubleshoot the Presto Error “‘PK\003\004’: command not found”?

Problem scenario
You try to start Presto from a command line interface. But you get an error message with garbled output like this:

./presto: line 1: $’PK\003\004′: command not found
./presto: line 2: $’ܢ\327H’: command not found
./presto: line 3: syntax error near unexpected token `)’
./presto: line 3: ۢ▒H▒▒W▒META-INF/MANIFEST.MF▒P▒j!▒▒▒?▒8▒▒ɸK)’

Possible solution #1
You may have downloaded a .jar file that could be unpacked.

How Do You Troubleshoot an Error Trying to Delete a VPC, Network Interface, or Subnet ID?

One (or more) of the following problems is applicable:

Problem scenario #1
You are trying to delete an network interface in AWS. But you get an error “You are not allowed to manage ‘ela-attach’ attachments.” What should you do?

Problem scenario #2
You are trying to delete a subnet from AWS’ VPC. But you get this error:

Note that the following subnets cannot be deleted: The following subnets contain one or more network interfaces, …

How Do You Troubleshoot the Message “/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require’: cannot load such file — foobar (LoadError)”?

Problem scenario
You are running Vagrant, Ruby or a Ruby application, but you get this error: “/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require’: cannot load such file — foobar (LoadError)”

What should you do?

Possible Solution #1
Try to run the original command with “sudo”. If that doesn’t work, use “gem list” to verify “foobar” is installed.

For Windows users, try to run the command or application as Administrator.