Skip to content

Instantly share code, notes, and snippets.

@ikurni
ikurni / ocp4-day2-readme
Last active April 20, 2023 10:43
OCP4 Day 2
Openshift Day 2 guidance :
-----------------------------------------------------------------------------------------------
Configure Openshift ingress operator to use node label “infra: true” and run router pods only in infra node
Edit openshift-ingress config :
# oc edit ingresscontrollers.operator.openshift.io/default -n openshift-ingress-operator
In the spec: section add below comment :
---
nodePlacement:
nodeSelector:
matchLabels:
@ikurni
ikurni / Working-with-Json-Patch
Last active November 9, 2022 21:36
Working with JSON Patch for Openshift OC Patch command
##Openshift OC Command using json type :
oc patch <object> <object> --type=json -p (sample)
##The original document :
{
"baz": "qux",
"foo": "bar"
}
The patch :
[
@ikurni
ikurni / enable-rook-ceph-tools
Created March 9, 2021 03:41
Enable Rook Ceph Tools in OCS 4+
### Run below command to enable rook-ceph-tools in OCS Cluster
oc patch OCSInitialization ocsinit -n openshift-storage --type json --patch '[{ "op": "replace", "path": "/spec/enableCephTools", "value": true }]'
@ikurni
ikurni / nodeSelector.config
Last active May 5, 2022 03:57
Schedule a POD to specific node
https://access.redhat.com/solutions/2178611
### How to Force a pod to schedule to a specific node using nodeSelector in OCP
Pods get scheduled to nodes based on the node labels. NodeSelector will get set either for the cluster, project, or pod to determine which node or group of nodes the pod will be scheduled to.
The easiest way to test and ensure a pod is scheduled to a node is by setting it at the project level. This can only be done by cluster-admins or users with elevated privileges.
# oc adm project <NAME> --node-selector='foo=bar'
@ikurni
ikurni / OCP4-Ingress-Certificate-Expired
Last active April 13, 2022 15:57
OCP 4 Ingress Certificate Expired after 2 Years of Deployment
# After 2 years deployment, suddenly Authentication and Console Operator is degraded, and after we check the operator status, it shows that
# the certificate is expired. To solve this, just delete the secret, and Operator will create new certificate. Assume we still use
# Openshift default certificate
### Delete Ingress CA Secret
oc project openshift-ingress-operator
oc get secret router-ca -oyaml > router-ca.yaml
oc delete secret router-ca
oc delete pod --all
oc get secret router-ca
@ikurni
ikurni / pods-stuck-in-terminating
Created April 27, 2021 16:03
Delete pods stuck in terminating
### Step 1
oc delete pod <podsname> -n myproject --grace-period=0 --force
### Step 2
oc edit pod <podsname>
#Remove deletionTimestamp
#Before: deletionTimestamp: 2019-12-31T11:40:28Z
#After: deletionTimestamp: null
#Remove Finalizers
#Before
@ikurni
ikurni / haproxy-set-headers-redirect-https
Last active October 12, 2021 15:07
HAProxy Replace URL Headers and Redirect HTTPS to HTTP
### Create SSL file for HTTPS traffic
mkdir /etc/haproxy/ssl
cat /root/wildcard.example.com.crt /root/wildcard.example.com.key >> /root/wildcard.example.com.pem
mv /root/wildcard.example.com.pem /etc/haproxy/ssl/
### Configure HAProxy.cfg to accept HTTPS, redirect HTTPS to HTTP and replace header to targeted URL
vi /etc/haproxy/haproxy.cfg
#---
#---------------------------------------------------------------------
@ikurni
ikurni / etcd-perf-check
Last active September 6, 2021 20:25
ETCD Performance Check
### Performance check command from etcd pod
# oc rsh <etcd-pod> -n openshift-etcd
$ etcdctl check perf --load="m"
$ etcdctl check perf --load='l'
$ etcdctl --write-out=table endpoint status
$ etcdctl --write-out=table endpoint health
$ etcdctl --write-out=table member list
### Collect metrics from the cluster.
@ikurni
ikurni / rhv-important-kb
Last active July 30, 2021 17:37
RHV Important KB
https://access.redhat.com/solutions/396753 --> Remove Locked Entities Manually
##How to Clean up Task in RHV :
#List Tasks :
/usr/share/ovirt-engine/setup/dbutils/taskcleaner.sh
#Kill Tasks :
/usr/share/ovirt-engine/setup/dbutils/taskcleaner.sh -t <taskID>
@ikurni
ikurni / force-bootstrap-machine-config
Created July 24, 2021 07:28
Force Re-run Openshift First Bootstrap
### If nodes is stuck in pulling images, or connection are too slow, sometime process can't move. Below is how to re-trigger ###
/run/bin/machine-config-daemon firstboot-complete-machineconfig