Search This Blog

Thursday, 24 March 2022

Openshift API

 

Openshift API


  1.  Get POD logs 

 

Get POD logs

  Get POD logs

 




OC Commands

 

OC Commands


# Login Commands

source /usr/local/etc/ocp4.config 

oc login -u kubeadmin -p ${RHT_OCP4_KUBEADM_PASSWD}  https://api.ocp4.example.com:6443 

# If Auth is configured then you can directly login with that account

oc login -u USER_NAME -p PASSWORD https://api.ocp4.example.com:6443

oc whoami

oc whoami -t     # To get token

# Cluster Commands

oc get clusterversion

oc describe clusterversion

oc get clusteroperators

# Node Commands

oc get nodes

oc adm top node

oc describe node master01

# Project Commands

oc get project  # To get projects 

oc project <PROJECT_NAME> # To connect to a project

oc project openshift-image-registry 

oc status # To check the status of the project

oc get events # To list all events from the connected project

oc get all # To list all about project

# Pod Commands

oc get pod -n <PROJECT_NAME>  # To list pods from specific project

oc get project  # To get projects 

oc get pod -n openshift-image-registry

oc get pod -A    # To list all pods from all projects

oc logs --tail <NO_LOGS_ToDisplay> <PROJECT_NAME> <POD_NAME>

oc logs --tail 3 -n openshift-image-registry  cluster-image-registry-operator-xx

oc logs <POD_NAME> -c <CONTAINER_NAME> # To get logs from container

oc get pod --loglevel 6

oc get pod --loglevel 10

# To get Node & it's services logs 

oc adm node-logs --tail <NO_LOGS_ToDisplay> -u kubelet <NODE_NAME>

oc adm node-logs --tail 1 -u kubelet master01

oc adm node-logs -u crio master01

oc adm node-logs master01

# To start shell session to the node

oc debug node/<NODE_NAME>

oc debug node/master01

chroot /host #To change file system to the node

# To check the services status which are running on host 

systemctl status kubelet

 systemctl status cri-o

crictl ps --name openvswitch # To check openvswitch pod running status


# PODMAN Commands

podman login registry.redhat.io # To login to redhat registry

# SKOPEO Commands

skoppeo inspect <IMAGE_URL>

skoppeo inspect docker://registry.redhat.io/rhel8/postgresql-13:1

# Deployment Commands

oc get deployment

oc edit deployment/<DEPLOYMENT_NAME>

oc edit deployment/psql    # To edit deployment configuration yaml file 

oc debug deployment/my-deployment-name --as-root # To create a test debug deployment pod to troubleshoot the issue

oc rsh POD_NAME # Opens a shell inside a pod to run shell commands interactively and non-interactively. 

oc cp /local/path POD_NAME:/container/path # Copies local files to a location inside a pod. 

oc port-forward POD_NAME local-port:remote-port # Creates a TCP tunnel from local-port on your workstation to local-port on the pod


CustomResourceDefinitions

 

CustomResourceDefinitions


An extension of the Kubernetes API that defines the syntax of a custom resource.

 

OLM - Operator Life Cycle Manager

 

OLM - Operator Life Cycle Manager


  1. An application that manages Kubernetes operators.     
  2. Provides an application that manages the deployment, resource utilization, updates, and deletion of operators that have been deployed through an operator catalog. The OLM itself is an operator that comes preinstalled with Openshift. 

OSDK(Operator SDK) - Operator Software Development Kit

 

OSDK(Operator SDK) - Operator Software Development Kit    


  1. An open source toolkit for building, testing, and packaging operators 
  2.  Provides a set of Golang libraries and source code examples that implement common patterns in operator applications. It also provides a container image and playbook examples that allow ou to develop operators using Ansible.  

 


Friday, 11 March 2022

Openshift Installation

 Installation Types

  1. Full-Stack Automation
  2. Pre-existing infrastructure 

Sequence to follow installing Openshift with Openshift installer 

  1. Create install-config.yaml
  2. Create Kubernetes manifests
  3. Create ignition configuration files
  4. Create the cluster
Kubernetes manifests and ignition configuration files are not exist already, these are created automatically in the create cluster step.

Deployment Process:

  1. The bootstrap machine boots, and then starts hosting the remote resources required for booting the control plane machines. 
  2. The control plane machines fetch the remote resources from the bootstrap machine and finish booting. 
  3. The control plane machines form an Etcd cluster. 
  4. The bootstrap machine starts a temporary Kubernetes control plane using the newly-created Etcd cluster. 
  5. The temporary control plane schedules the control plane to the control plane machines. 
  6. The temporary control plane shuts down and yields to the control plane. 
  7. The bootstrap node injects components specific to OpenShift into the control plane. 
  8. Finally, the installer tears down the bootstrap machine.
 Customizing an OpenShift Installation

The OpenShift installer allows very little customization of the initial cluster that it provisions. Most customization is performed after installation, including: 

• Defining custom storage classes for dynamic storage provisioning. 
• Changing the custom resources of cluster operators. 
• Adding new operators to a cluster. 
• Defining new machine sets.
 

To enable cluster management with OC command
export KUBECONFIG=${HOME}/ocp4-cluster/auth/kubeconfig

oc get clusterversion -o jsonpath='{}.items[].spec.clusterID}{"\n"}'

#Deleting an Openshift Cluster

openshift-install destroy cluster --dir=${HOME}/ocp4-cluster


Ansible_Notes

   ansible -i inventory.ini -m ping all   # inventory.ini it will ping to the hosts which are in inventory # ansible -i inventory.ini -m pin...