Friday, November 6, 2020

kind(multi-node (including HA) clusters)

kind is a tool for running local Kubernetes clusters using Docker container “nodes”.

kind was primarily designed for testing Kubernetes itself, but may be used for local development or CI.

Why kind?

  • kind supports multi-node (including HA) clusters
  • kind supports building Kubernetes release builds from source
    • support for make / bash / docker, or bazel, in addition to pre-published builds
  • kind supports Linux, macOS and Windows
  • kind is a CNCF certified conformant Kubernetes installer

Installation and usage

NOTE: kind does not require kubectl, but you will not be able to perform some of the examples in our docs without it. To install kubectl see the upstream reference here https://kubernetes.io/docs/tasks/tools/install-kubectl/
On Linux:
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.9.0/kind-linux-amd64
chmod +x ./kind
mv ./kind /some-dir-in-your-PATH/kind

On Mac (homebrew):
brew install kind

On Windows:
curl.exe -Lo kind-windows-amd64.exe https://kind.sigs.k8s.io/dl/v0.9.0/kind-windows-amd64
Move-Item .\kind-windows-amd64.exe c:\some-dir-in-your-PATH\kind.exe

Creating a Cluster 

Creating a Kubernetes cluster is as simple as 
kind create cluster
kind create cluster --name kind-2

Interacting With Your Cluster

After creating a cluster, you can use kubectl to interact with it by using the configuration file generated by kind.
By default, the cluster access configuration is stored in ${HOME}/.kube/config if $KUBECONFIG environment variable is not set.
When you list your kind clusters, you will see something like the following:
kind get clusters
kind
kind-2
In order to interact with a specific cluster, you only need to specify the cluster name as a context in kubectl:
kubectl cluster-info --context kind-kind
kubectl cluster-info --context kind-kind-2


Deleting a Cluster

If you created a cluster with kind create cluster then deleting is equally simple:
kind delete cluster

If the flag --name is not specified, kind will use the default cluster context name kind and delete that cluster.

Resources: https://kind.sigs.k8s.io/docs/user/quick-start 

Saturday, October 17, 2020

Setting Multiple Profile for AWS CLI


AWS CLI

The AWS Command Line Interface (AWS CLI) is an open source tool that enables you to interact with AWS services using commands in your command-line shell.

AWS CLI versions

The AWS CLI is available in two versions and information in this guide applies to both versions unless stated otherwise.

Version 2.x – The current, generally available release of the AWS CLI that is intended for use in production environments. This version does include some "breaking" changes from version 1 that might require you to change your scripts so that they continue to operate as you expect.

Version 1.x – The previous version of the AWS CLI that is available for backwards compatiblity.

Named profiles
A named profile is a collection of settings and credentials that you can apply to a AWS CLI command. When you specify a profile to run a command, the settings and credentials are used to run that command.

The AWS CLI supports using any of multiple named profiles that are stored in the config and credentials files. You can configure additional profiles by using aws configure with the --profile option, or by adding entries to the config and credentials files.

Execute the below command, it will ask access key and secret key for the ‘user1’
$ aws configure --profile user1

$ ~/.aws/credentials

[default] 
aws_access_key_id=AKIAIOSFODNN7EXAMPLE aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY 

[user1] 
aws_access_key_id=AKIAI44QH8DHBEXAMPLE aws_secret_access_key=je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY


Each profile can specify different credentials—perhaps from different IAM users—and can also specify different AWS Regions and output formats.

$ cat ~/.aws/config

[default] 
region=us-west-2
 output=json 

[profile user1] 
region=us-east-1 
output=text

Using profiles with the AWS CLI

To use a named profile, add the --profile profile-name option to your command. The following example lists all of your Amazon EC2 instances using the credentials and settings defined in the user1 profile from the previous example files.

$ aws ec2 describe-instances --profile user1

To use a named profile for multiple commands, you can avoid specifying the profile in every command by setting the AWS_PROFILE environment variable at the command line.

$ export AWS_PROFILE=user1

Now you can use AWS CLI without specifying the --profile in the following command.