Friday, June 7, 2024

A Comprehensive Guide to Essential `kubectl` Commands

What is kubectl?

kubectl is a command-line interface (CLI) tool that interacts with the Kubernetes API server by authenticating with the Master Node of the cluster and making API calls to execute management tasks.

By using kubectl, users can communicate with the Kubernetes control plane, which manages the cluster's overall state.

It serves as the primary means of managing Kubernetes clusters, allowing users to deploy applications, inspect and manage cluster resources, and view logs.

Why kubectl is Important?

  • Centralized Management: kubectl provides a unified interface to manage all aspects of Kubernetes clusters, making it easier to perform administrative tasks.
  • Flexibility: It supports both imperative and declarative management approaches, allowing users to choose the method that best suits their workflow.
  • Accessibility: Being a CLI tool, kubectl is lightweight and can be used from various environments, including local machines, remote servers, and CI/CD pipelines.
  • Essential for All Users: Whether you are just starting out with Kubernetes or are an experienced administrator, mastering kubectl is crucial for effective cluster management.

What Will You Learn?

In this blog, we will cover essential kubectl commands, including:

  • Basic cluster information retrieval
  • Pod management
  • Deployment handling
  • Service and networking operations
  • ConfigMaps and secrets management
  • Logs and troubleshooting techniques

Getting Started with kubectl

Before diving into the commands, ensure you have kubectl installed and configured to communicate with your Kubernetes cluster. You can install kubectl by following the instructions on the official Kubernetes documentation.

kubectl version --client

This command checks your kubectl version and confirms that it is installed correctly.

Basic Cluster Information

  1. View Cluster Information:
kubectl cluster-info

This command provides information about the Kubernetes cluster, including the master and services running.

  1. Get Nodes:
kubectl get nodes

This command lists all nodes in the cluster along with their status, roles, age, and version.

  1. Describe Node:
kubectl describe node <node-name>

Replace <node-name> with the name of your node to get detailed information about the node, including capacity, allocations, labels, and more.

Working with Pods

  1. Get Pods:
kubectl get pods

This command will list all pods in the default namespace. If you wish to list pods in a specific namespace, use:

kubectl get pods -n <namespace>
  1. Describe Pod:
kubectl describe pod <pod-name>

This command provides detailed information about a specific pod, including events, status, containers, and more.

  1. Create Pod:

You can create pods using Kubernetes manifests(YAML or JSON). For example, to create a pod defined in pod.yaml:

kubectl apply -f pod.yaml
  1. Delete Pod:

If you want to delete a specific pod use:

kubectl delete pod <pod-name>

You can also delete pods using labels:

kubectl delete pod -l <label-key>=<label-value>

Managing Deployments

  1. Get Deployments:
kubectl get deployments

This command lists all deployments in the default namespace. For a specific namespace, use:

kubectl get deployments -n <namespace>
  1. Describe Deployment:
kubectl describe deployment <deployment-name>

This command provides detailed information about a specific deployment.

  1. Scale Deployment:
kubectl scale deployment <deployment-name> --replicas=<number>

This command scales the number of replicas in a deployment.

  1. Update Deployment:

To update a deployment, modify the deployment YAML file and apply the changes:

kubectl apply -f deployment.yaml
  1. Roll Back Deployment:
kubectl rollout undo deployment <deployment-name>

This command rolls back a deployment to the previous revision.

Services and Networking

  1. Get Services:
kubectl get services

This command lists all services in the default namespace. For a specific namespace, use:

kubectl get services -n <namespace>
  1. Describe Service:
kubectl describe service <service-name>

This command provides detailed information about a specific service.

  1. Expose Pod as a Service:
kubectl expose pod <pod-name> --port=<port> --target-port=<target-port> --name=<service-name>

This command exposes a pod as a service. Replace <port>, <target-port>, and <service-name> with appropriate values.

ConfigMaps and Secrets

  1. Create ConfigMap:
kubectl create configmap <configmap-name> --from-literal=<key>=<value>

This command creates a ConfigMap from literal values. You can also create from files:

kubectl create configmap <configmap-name> --from-file=<file-path>
  1. Get ConfigMaps:
kubectl get configmaps

This command lists all ConfigMaps in the default namespace.

  1. Describe ConfigMap:
kubectl describe configmap <configmap-name>

This command provides detailed information about a specific ConfigMap.

  1. Create Secret:
kubectl create secret generic <secret-name> --from-literal=<key>=<value>

This command creates a generic secret from literal values. You can also create from files:

kubectl create secret generic <secret-name> --from-file=<file-path>
  1. Get Secrets:
kubectl get secrets

This command lists all secrets in the default namespace.

  1. Describe Secret:
kubectl describe secret <secret-name>

This command provides detailed information about a specific secret.

Logs and Troubleshooting

  1. View Pod Logs:
kubectl logs <pod-name>

This command fetches logs from a specific pod. For pods with multiple containers, specify the container:

kubectl logs <pod-name> -c <container-name>
  1. Exec into Pod:
kubectl exec -it <pod-name> -- /bin/bash

This command opens an interactive terminal session inside a specific pod. Replace /bin/bash with the shell available in your container.

  1. Port Forwarding:
kubectl port-forward <pod-name> <local-port>:<pod-port>

This command forwards a local port to a port on the pod, useful for accessing services locally.

  1. Get Events:
kubectl get events

This command lists all events in the cluster, useful for debugging issues.

Conclusion

Mastering kubectl commands is essential for effectively managing Kubernetes clusters. This blog covers essential commands, providing a solid foundation for any Kubernetes administrator. As you become more comfortable with these commands, you'll find managing your clusters more efficient and intuitive.

Remember, the key to mastering kubectl is practice. Regularly use these commands in your daily workflows, explore the Kubernetes documentation for more details, and keep experimenting with different scenarios to deepen your understanding.

Happy Kuberneting!

Monday, November 11, 2019

What’s new in Oracle WebLogic Server 12.2.1.4?


As most of you are already aware that Oracle has announced its fourth patch set release for Oracle WebLogic Server 12c R2 numbered 12.2.1.4 as part of its overall OFM 12.2.1.4 release. I have already posted a blog with a list of products that were released in this version, click here to check the same. In this blog I will try to cover the new and deprecated features of this newbie in the family.

I will be limiting this blog only to Weblogic and I will blog another one for SOA and its components.

Oracle Weblogic server 12.2.1.4 is the fourth one of the 12c R2 family. This is the patch set release for 12.2.1.X, delivered for incorporating bug fixes identified in its prior release (12.2.1.3). Looks like Oracle intentionally limited new features between Oracle WebLogic Server 12.2.1.3 and 12.2.1.4 to make the adoption easy for the existing 12.2.1.X customers or may be planning big for its next release 14.1.1.

Yes, you read it right there is no 13, {IS ORACLE SCARED TOO!!} I don’t think so, as they have already released Java 13, OEM13… Oracle let us know 😉.  Next release would be 14.

Oracle announced its beta program for WebLogic Server and Coherence with the version numbering 14.1.1 on September 17, 2019. With this Oracle has brought the same old confusion with version numbering concept with different version numbers for database and Middleware products . We were aligned with Middleware12c, but with announcement of the release 14 we are back to the same old confusion of version numbering. Oracle database releases are now following the version numbering with the years, e.g. Oracle Database 18c (2018), Oracle Database 19c (2019). I still don’t understand why they numbered it 14 for its next release. Oracle please help us in understanding this version numbering for Fusion middleware and please align with same version numbering concept you are following for Databases.

Ohhh, this is going in different direction let’s jump back to Oracle Weblogic server 12.2.1.4.

It is important for the customers to note that Oracle Weblogic server 12.2.1.4 is defined as a final maintenance release in a release series of 12.2.X and to continue with Long Term Support (LTS) formerly know as Terminal release. Which means error correction support will continue for 12.2.1.4 through the Premier and Extended Support dates documented in the Lifetime Support Policy and importantly customers who are adopting 12.2.1.4 can have this version as their Production platform for many years (hopefully).

Below are the some of the features that were added in Oracle WebLogic Server version 12.2.1.4.0

JMS

This is one service where I found some serious improvements were brought in.

Per-JVM Load Balancing:

We can now enable Per-JVM load balancing instead of Per-Member message load balancing.

Per-Member load balancing considers all active members of the distributed destination as candidates when considering affinity or other heuristics. It helps in evenly distributing messages among all members, but if there is any fail-over of a member or migrate, it can lead to some JVMs getting more messages than others.

Per-JVM Load balancing considers only one member of the distributed destination on each WebLogic Server JVM regardless of the number of members hosted by each JVM. This not only helps in evenly distributing messages among all WebLogic servers in a cluster but also retains failed-over members to recover and process the unprocessed messages of this failed over members.

Failover Limit:

We can now specify a limit for the number of cluster-targeted JMS instances that can fail over to a JVM.

This will help in preventing too many JMS instances failing over to a single JVM.

Property
Default Value
Fail Over Limit
-1

The default value -1 means no fail over limit
Value 0 prevents any failovers of the JMS instances so only one instance 1 instance will run per server.
Value 1 allows one failover instance on each server, so no more than two instances will run per server. This number can be increased as needed.

Configuration Overriding

Configuration Overriding is also called situational configuration used to customize a Weblogic domain configuration without modifying the domain’s actual configuration files. This feature will be very helpful in situations where you have servers running in MSI mode and want to do configurational changes without starting our Admin Server. Configuration Overriding bypasses the Admin Server as the primary means of distributing configuration information to Managed Servers.

In previous releases, there was limitation where it was required to provide an expiration time and for that reason it was named as Temporary Configuration Overriding. This limitation is now removed.

Security

AES 256–bit encryption:

From this version (12.2.1.4) Weblogic server uses AES 256–bit encryption to protect sensitive configuration and runtime values. Only new domains created in this release 12.2.1.4 use AES 256–bit encryption, domain upgraded to 12.2.1.4 from previous releases will not be able to use AES 256–bit encryption and will run on AES 128–bit encryption.

SAML encryption and signing:

From WebLogic 12.2.1.4.0, “Only accept signed assertions” setting is selected by default. It was not required in previous releases, which could be used to bypass authentication and gain access as an arbitrary user.

The following new encryption attributes have been added to the ‘SingleSignOnServicesMBean’.

  • AssertionEncryptionEnabled
  • KeyEncryptionAlgorithm
  • DataEncryptionAlgorithm
  • MetadataEncryptionAlgorithms
  • AssertionEncryptionDecryptionKeyAlias
  • AssertionEncryptionDecryptionKeyPassPhrase
  • AssertionEncryptionDecryptionKeyPassPhraseEncrypted

JEP 290 Enhancements:

In WebLogic 12.2.1.4.0, a system property ‘weblogic.oif.serialFilterLogging’ has been added that you can use to log the current blacklist classes and packages. The scope of the default filter is also now set to ‘global’.



Now let’s have a look on the deprecated functionalities

  1. Multitenant domain partitions, resource groups, resource group templates, virtual targets, and Resource Consumption Management are deprecated in this release (12.2.1.4.0) and will be removed in the next release.
  2. Simple Network Management Protocol (SNMP) v1 and v2 are now deprecated and the default version is SNMPv3.
  3. Active-Active XA Transaction Recovery (automated cross-site XA transaction recovery) is deprecated in WebLogic Server 12.2.1.4.0 and will be removed in the next release. 
  4. ValidateCertChain Java utility is now deprecated for the below file-based option.

·         java utils.ValidateCertChain -file pemcertificatefilename
·         java utils.ValidateCertChain -pem pemcertificatefilename
·         java utils.ValidateCertChain -pkcs12file pkcs12filename password

Oracle recommends using the -pkcs12store or the -jks keystore options instead.

·         java utils.ValidateCertChain -pkcs12store pkcs12storefilename
·         java utils.ValidateCertChain -jks alias storefilename [storePass]


Enjoy the new release!!!


References:



Sunday, October 13, 2019

Oracle Fusion Middleware 12.2.1.4.0 is Released.


On Friday, 27th September 2019, Oracle announced the launch of the new long-awaited version of Oracle Fusion Middleware 12c (12.2.1.4.0), this is after two years now the next release of Oracle Fusion Middleware is available.

This release includes the following products:
  • Oracle SOA Suite and Business Process Management 12c (12.2.1.4.0)
  • Oracle B2B and Healthcare 12c (12.2.1.4.0)
  • Oracle Business Intelligence 12c (12.2.1.4.0)
  • Oracle Coherence 12c (12.2.1.4.0)
  • Oracle Data Integrator 12c (12.2.1.4.0)
  • Oracle Enterprise Data Quality 12c (12.2.1.4.0)
  • Oracle Forms and Reports 12c (12.2.1.4.0)
  • Oracle Fusion Middleware Infrastructure 12c (12.2.1.4.0)
  • Oracle Fusion Middleware WebLogic Server Plug-In 12c (12.2.1.4.0)
  • Oracle GoldenGate Studio 12c (12.2.1.4.0)
  • Oracle GoldenGate Veridata 12c (12.2.1.4.0)
  • Oracle HTTP Server 12c (12.2.1.4.0)
  • Oracle Identity and Access Management 12c (12.2.1.4.0)
  • Oracle Internet Directory 12c (12.2.1.4.0)
  • Oracle JDeveloper Studio 12c (12.2.1.4.0)
  • Oracle Managed File Transfer 12c (12.2.1.4.0)
  • Oracle MapViewer 12c (12.2.1.4.0)
  • Oracle Real-Time Integration Business Insight 12c (12.2.1.4.0)
  • Oracle Service Bus 12c (12.2.1.4.0)
  • Oracle TopLink 12c (12.2.1.4.0)
  • Oracle Traffic Director 12c (12.2.1.4.0)
  • Oracle Unified Directory 12c (12.2.1.4.0)
  • Oracle WebCenter Content 12c (12.2.1.4.0)
  • Oracle WebCenter Portal 12c (12.2.1.4.0)
  • Oracle WebCenter Sites 12c (12.2.1.4.0) 
  • Oracle WebLogic Server 12c (12.2.1.4.0)

This release also includes the following VM Templates for Private Cloud Appliance:
  • Oracle VM Virtual Appliance for WebLogic Server and Coherence (12.2.1.4.0)
  • Oracle VM Virtual Appliance for Infrastructure (12.2.1.4.0)
  • Oracle VM Virtual Appliance for SOA Suite (12.2.1.4.0)
  • Oracle VM Virtual Appliance for Internet Directory (12.2.1.4.0)
  • Oracle VM Virtual Appliance for Identity and Access Management (12.2.1.4.0)
  • Oracle VM Virtual Appliance for HTTP Server (12.2.1.4.0)
  • Oracle VM Virtual Appliance for Traffic Director (12.2.1.4.0)
  • Oracle VM Virtual Appliance for Traffic Director Collocated (12.2.1.4.0)

As my main focus is on Weblogic & SOA, i will try the new release and post the new features and my personal view in my next blog.

Enjoy the new release!!!

A Comprehensive Guide to Essential `kubectl` Commands

What is kubectl ? kubectl is a command-line interface (CLI) tool that interacts with the Kubernetes API server by authenticating with the M...