Why Cannot You Upload Different Docker Images to a Given Docker Repository?

Problem scenario
You have a Docker repository.  You know its name in the Docker registry.  You are having trouble uploading different images to the repository.  What should you do?

Solution
You must use a different Docker repository for each image.  A repository can only hold different versions of the same image.  But only one image can be stored in a repository.  This link provides more details.

What Is The Difference between a Docker Registry and a Docker Repository?

Question
You know Docker images can be stored in repositories.  What is the difference between a Docker registry and a Docker repository?

Answer
A Docker registry is a group of Docker repositories.  For more information, see this external page.

How Do You Configure an Amazon VPC?

Problem scenario
You want to use a VPC in AWS.  What do you do to create one?

Solution
1.  Log into the AWS web console.
2.  Go here: https://aws.amazon.com/vpc/
3.  Click "Get started with Amazon VPC".
4.  Click "Launch VPC Wizard".
5.  Click "Select".
6.  Change configurations as desired.  At a minimum click the "Availability Zone" to choose the region that is most appropriate for your needs (i.e., the closest one).
7.  Click "Create VPC".
8.  Click "OK".

How Do You Create a Class for Objects with Many Data Members and Access One Specific Data Member in Groovy?

Problem scenario
You want to use Groovy to create a class and an object that is composed of many individual member data types.  How do you do this and access an individual data type of the object?

Solution
This Groovy program creates two objects from the same class using different syntax.  One method uses syntax "[]" and another method uses the "new" keyword.

@groovy.transform.Canonical
class Program {
    String mem1 = ""
    String mem2 = ""
    String mem3 = ""
    String mem4 = ""
    String mem5 = ""
    String mem6 = ""
    String mem7 = ""
    String mem8 = ""
    String mem9 = ""
}

programsv1 = new Program( "1", "2", "3", "4", "5", "6", "7", "8", "9")
Program[] programsV2 = [[" ", "x", " ", " ", " ", " ", " ", " ", " ",]]

println programsv1.mem8
println programsV2.mem2

What is “continuous integration” (or CI or “continual integration”)?

Question
What is "continuous integration" or "continual integration"?

Answer
Continuous integration (or continual integration) is the convergence of code from two or more developers via an automated process.  We arrived at this definition from summarizing and extrapolating from the following three quotes:

  1. "Continuous Integration is merging all code from all developers to one central branch of the repo many times a day trying to avoid conflicts in the code in the future."  (This was taken from Stackify.com.)
  2. "Continuous Integration (CI) is a development practice from Extreme Programming that requires developers to integrate code into a mainline as often as possible, at least once a day, and each check-in is then verified by an automated build that compiles the code and runs the suite of automated tests against it, allowing teams to detect problems early."  (This was taken from Medium.com.)
  3. "Continuous Integration (CI): automated build and execution of at least unit tests to prove integration of new code with existing code, but preferably integration tests (end-to-end)."  (This was taken from StackOverflow.com.)

The CI process can happen in Azure DevOps pipelines with a single software engineer. In many contexts the deployment of the artifact (e.g., of the compiled code from the CI process), is separate. From a pragmatic perspective or loose business context, you may read/hear/see things that refer to the CI process involving code being deployed. However, we are aware that the industry tends to have adopted a view that the CD process is discretely different from the CI process. That is, the transference of the new binary file or live script to a server in development, QA or production environments is not part of the CI process; this narrow definition of CI can be relevant to build engineers, site reliability engineers and DevOps engineers.

One definition of CI is to merge a branch of code to the main branch daily. "…if you merge your branch to (not just from) mainline once a day, you're OK. If you're not doing that, you're not doing continuous integration." This was taken from page 391 of Continuous Delivery by Humble and Farley.

While we prefer the term "continual integration" (see the home page for more on this), we acknowledge a highly-voted-up answer on StackOverflow.com says this:  "Continuous Integration is a strategy for how a developer can integrate code to the mainline continuously - as opposed to frequently."  We think the term "continually" would be appropriate.  We fail to see how code could be integrated on a "continuous" and not a "frequent" basis.  But given the newness of technology and the related terms, we appreciate that there are more than one valid interpretations of continuous/continual integration.


To learn more about the difference between CI and CD, see this posting. To read more about Jenkins, click here.

How Do You Troubleshoot the kubectl Message “Connection error: Unable to connect to the server:” with AWS?

Problem scenario
You are using Kubernetes in AWS.  When using a kubectl command you get this error: "Connection error: Unable to connect to the server:  getting credentials: exec: exit status 1  ... Could not get token: AccessDenied: Access denied"

What should you do?

Possible Solution #1
Was the user who created the Kubernetes cluster a different user from the user that is configured with your AWS CLI? Configure your AWS CLI to be the same user as the user that created the cluster.  Then try the command again.

Possible Solution #2
Check your Security Groups.  Is there an AWS firewall rule blocking connectivity?

Possible Solution #3
Has an Amazon Role been created? If not and you need assistance with this, see this posting.

Possible Solution #4
To ensure you have the correct AWS access key and secret key ID, create a new cluster with your AWS CLI credentials.

The command will look something like this (replace "contint" with the name you want to give your cluster):

aws eks create-cluster --name contint --role-arn arn:aws:iam::123456789:role/foobar --resources-vpc-config subnetIds=subnet-87cb36dd,subnet-2e1ba163,subnet-d355a3c1,securityGroupIds=sg-33e3abbe

The hyperlink in prerequisite ii can help you determine the "arn.../foobar" value.  If you do no know what subnet IDs or security group IDs to use, try these commands if you already have an EKS cluster running:

aws eks list-clusters

aws eks describe-cluster --name contint   # where "contint" is the name of the cluster that the above command produces

If you want more thorough directions for starting over, see one of these postings:
How Do You Use Amazon Elastic Kubernetes Service with the Web UI?
How Do You Use Amazon Elastic Kubernetes Service with the CLI?

You may also want to see these postings:
How Do You Find the Subnet ID values in AWS?
How Do You Find the Security Group ID Values in AWS?

What Are ARM Templates (for Azure)?

Question
What are ARM (Azure Resource Manager) templates?

Answer
ARM templates are JSON files that have six element definitions, of which three are mandatory:

$schema
contentVersion
parameters
variables
resources
outputs

The elements $schema, contentversion, and resources are mandatory.

For more information see these links:
https://medium.com/@zaab_it/azure-resource-manager-template-101-1ccddc797f65

How Do You Use Amazon Elastic Kubernetes Service with the CLI?

Problem scenario
You want to deploy Kubernetes to AWS.  How do you use Amazon EKS to create a cluster with the AWS CLI?

Solution
Prerequisites

i.  This assumes that your AWS CLI has been installed.  If you need assistance with this, see this posting.
ii.  This assumes that you have a role created.  If you need assistance with this, see this posting.
iii. You need to have kubeadm installed. The server with it needs to have 2 vCPUs and 1.7 GB of RAM or the installation will fail. If you need assistance installing it, see this posting.

Procedures
The command will look something like this (replace "contint" with the name you want to give your cluster):

aws eks create-cluster --name contint --role-arn arn:aws:iam::123456789:role/contint1 --resources-vpc-config subnetIds=subnet-87cb36dd,subnet-2e1ba163,subnet-d355a3c1,securityGroupIds=sg-33e3abbe

If you need help on how to craft the above statement, read the following. (After running the command be prepared to wait 15 minutes for the cluster to be created.)

The hyperlink in prerequisite ii can help you determine the "arn.../contint1" value. 

If you do not know the role-arn value, run this query:

aws iam list-roles | jq -r '.Roles[] | select(.AssumeRolePolicyDocument.Statement[].Principal.Service=="eks.amazonaws.com")'

If you do no know what subnet IDs or security group IDs to use, try these commands if you already have an EKS cluster running:

aws eks list-clusters

aws eks describe-cluster --name contint # where "contint" is the name of the cluster that the above command produces

If you do not have EKS clusters set up yet, run these commands to find your subnet IDs and Security Group ID:

For finding the default VPC ID (for the next suggestions), use this command: aws ec2 describe-vpcs | jq -r '.Vpcs[] | select(.IsDefault)'

For finding the Subnets, say, if you know the VPC you are looking for vpc-abc123, use this command but substitute the vpc-abc123 accordingly:
aws ec2 describe-subnets | jq -r '.Subnets[] | select(.VpcId=="vpc-abc123")' | grep SubnetId

To find the security group Ids if you know the VPC you are looking for vpc-abc123, use this command but substitute the vpc-abc123 accordingly:
aws ec2 describe-security-groups | jq -r '.SecurityGroups[] | select(.VpcId=="vpc-abc123")' | grep -i groupid

If you have a simple AWS environment, these can be useful (but are not necessary if you ran the more complex commands with "jq" above):
#aws ec2 describe-subnets | grep -i subnetid
#aws ec2 describe-security-groups | grep -i groupid

aws eks --region us-east-2 update-kubeconfig --name contint #change "us-east-2" to the region of your choice

To install the AWS IAM Authenticator, run the following commands (but replace "ec2-user:ec2-user" with the username and group name of your choice):

curl -Lk https://amazon-eks.s3.us-west-2.amazonaws.com/1.17.9/2020-08-04/bin/linux/amd64/aws-iam-authenticator > /tmp/aws-iam-authenticator

# If you need a newer version in the future, go here: https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html

sudo cp /tmp/aws-iam-authenticator /usr/local/bin

sudo chown ec2-user:ec2-user /usr/local/bin/aws-iam-authenticator

sudo chmod u+x /usr/local/bin/aws-iam-authenticator

If you want to create nodes, see this posting. Before you run the following command, be sure that there are two CPUs on your server (e.g., with cat /proc/cpuinfo) and be sure that Docker has been installed: sudo kubeadm init

You may want to run these commands to get flannel working such that the worker nodes are ready:

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml

kubectl -n kube-system apply -f https://raw.githubusercontent.com/coreos/flannel/bc79dd1505b0c8681ece4de4c0d86c5cd2643275/Documentation/kube-flannel.yml

Finally, if the pods are not in the "Ready" state and "kubectl describe pods" shows an error about the CNI plugin not working or subnet.env not existing, you may want to log into the worker nodes and create /run/flannel/. This directory could house a copy of subnet.env. This file can sometimes be found on the worker nodes in /etc/flannel/subnet.env. The contents of the file should be as follows:

FLANNEL_NETWORK=10.244.0.0/16
FLANNEL_SUBNET=10.244.0.1/24
FLANNEL_MTU=1450
FLANNEL_IPMASQ=true  

(The four lines above were taken from this page.)

How Do You Create an AWS User with Web Console Access to View EKS Clusters in the AWS Console?

One of the following problem scenarios apply.

Problem scenario #1
You want an AWS user to be able to log into the web console and view EKS clusters.  How do you do this?

OR

Problem scenario #2
You are using AWS and when you log into the AWS Console via a web browser with a user who is a member of a Group with two EKS policies, you go to Amazon EKS. But you see this error:

AccessDeniedException User: arn:aws:iam::12345678910:user/funuser is not authorized to perform: eks:ListClusters on resource: arn:aws:eks:us-west-2:12345678910:cluster/*

Can an IAM Role be used with the web console? How do you create an AWS user with web console access to view EKS clusters in the AWS Console?

Solution
Prerequisites

i.  This solution assumes you have an AWS user created with console access.  If you need help with this, see this posting.

ii.  This solution assumes the user has two EKS policies apply (either through a group or through direct attachment).  If you need help with this, see this posting.

iii. This assumes you have an ARN for a role that can manage Kubernetes clusters.  If you need help with creating this IAM Role that can manage Kubernetes/EKS clusters, see this posting.

If the role exists and you need help finding/determining the ARN, do either a or b below:

a.  If you have AWS CLI configured for the region that has a cluster in EKS, run this command to find the ARN: aws sts get-caller-identity

b.  If the role has already been created and you need help determining this, go here: https://console.aws.amazon.com/iam/home?
Then go to "Roles" on the left.  Find the name i.e., "goodrole" and click on it as it should be hyperlinked.  The "Role ARN" should be near the top.  It will be in this format: "arn:aws:iam::12345678910:role/rolename"  
You will need this value later.

Procedures
1.  Log into the AWS console.
2.  Go to this link: https://console.aws.amazon.com/iam/
3.  Go to "Policies" then click "Create policy."  
4.  Go to the JSON tab.  Paste this:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "eks:*"
            ],
            "Resource": "*"
        }
    ]
}

5.  Click "Review policy".
6.  Enter any name you want.  Remember the name for later.
7.  Click "Create Policy".
8.  Go to "Policies" then click "Create policy."  
9.  Go to the JSON tab.  Paste this but replace "arn:aws:iam::12345678910:role/rolename" with the ARN of the role that allows for the managing of EKS clusters (footnote #1):

{
    "Version": "2012-10-17",
    "Statement": [
    {
        "Sid": "PolicyStatementToAllowUserToPassOneSpecificRole",
        "Effect": "Allow",
        "Action": [ "iam:PassRole" ],
        "Resource": "arn:aws:iam::12345678910:role/rolename"
    }
    ]
}

10.  Click "Review policy".
11.  Enter any name you want.  Remember this name for later too.
12.  Click "Create Policy".
13.  Click on "Users" on the left.
14.  Click on the user that you want to be able to have full EKS rights (the user with the problem).
15.  Click on the "Permissions" tab then the "Add permissions" button.
16.  At the top, click on  "Attach existing policies directly."
17.  Select each of the two policies created earlier (based on their custom names from steps #6 and #11 above).
18.  Click "Next: Review".
19.  Click "Add permissions".
20.  Now you are done.  The user may have to refresh the web UI (but not necessarily log out).


(1) To find this go to IAM -> Roles and click on the Role you want to find.

How Do You Use Amazon Elastic Kubernetes Service with the Web UI?

Problem scenario
You want to deploy a Kubernetes cluster in AWS.  How do you use Amazon EKS with the web UI?

Solution
Prerequisites

i.  Optional:  It is recommended to create a separate VPC for each cluster (according to Amazon's documentation here).  If you need to create a VPC, see this posting.

ii.  You need a Linux server with kubectl installed on it.  To install kubectl, on Ubuntu Linux running in AWS, run this command:  sudo snap install kubectl --classic

To install kubectl on a CentOS/RHEL/Fedora server, follow step #1 of this posting and ignore the other steps.

iii.  Install the aws-iam-authenticator on the same Linux server with kubectl.  If you need directions, see this posting.

iv.  Mentally determine which AWS user will run the kubectl commands if one exists.  This console user account (via any one of its access key and secret key pairs) needs to be the one to create the cluster too.  Part 2 of the Procedures below will require you to have access to the web UI console of AWS with this user.  

If you need assistance creating an AWS user (and an AWS group) for this purpose, follow two sets of directions in this order: First follow the steps in this posting.  Secondly do this posting.

v.  These directions require you to configure the AWS CLI with the user account determined in the step above.  "While the AWS CLI is not explicitly required to use Amazon EKS, the update-kubeconfig command greatly simplifies the kubeconfig creation process."  Taken from Amazon's documentation.

Click here if you want directions to install the AWS CLI.  Remember to use the access key (and its secret key) when following those linked directions that are the ones associated with the user referred to in prerequisite iv (above) of these directions.

Part 1  (Performed from a web browser.)
Create the Kubernetes cluster by following this section's directions:
1.  Log into the AWS Console (in a web browser) with the same user associated with the AWS CLI (which may have one, two, or more access keys).
2.a.  Go to this URL:  https://console.aws.amazon.com/eks/home
2.b.  Make sure you are in the region that you want to be in (e.g., us-west-1 or Northern California).
3.  Enter a cluster name (such as "Contint"), then click "Next step."
4.  Configuring the cluster should be self-explanatory.  
    a.  If the role you want is in the drop down box, select it, then choose the subnets and security groups as you desire.  Then click the "Create" button in the lower right-hand corner.  Then skip to step #6.  If you need a role, follow substeps b through k below.  
    b.  If you need to create a Role, go here in a different tab: https://console.aws.amazon.com/iam/home?#/roles
    c.  Click "Create role" (a blue button).  
    d.  The type of trusted entity (at the top) should be "AWS Service" (a button like option near the top).
    e.  Click the hyperlink for "EKS".
    f.  Click "Next: Permissions" (a blue button).
    g.  Click "Next: Tag" (a blue button).  
    h.  At your option you may enter a key name.  Click the "Next: Review" blue button in the lower right-hand corner.
    i.  Type in a "Role name" in the appropriate field.  Click the "Create role" blue button in the lower right-hand corner.    
    j.  Check individual security groups as you desire.  
    k.  Click "Create" (an orange button).
5.  You may need to wait a few minutes.  While it is being created you may want to click the refresh button (a semi-circular arrow near the "Delete" button).
6.  You will need various values from this web UI screen in the next step.

Part 2  (From a Linux command prompt)
7.  From the Linux back-end run this command:  aws eks update-kubeconfig --name Contint

We recommend you run the command above, but replace "Contint" with the name of the cluster.  If you do not want to automatically create the config file, you can manually create it.  To do so, follow these directions. If you need help using a new IAM user, see this posting.