Skip to content

Instantly share code, notes, and snippets.

name: AKS Deployment
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
AZURE_CONTAINER_REGISTRY: "repo.azurecr.io"
# Logs in to the Azure Container Registry
- uses: Azure/docker-login@v1
with:
login-server: ${{ env.AZURE_CONTAINER_REGISTRY }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
# Build and push image to Azure Container Registry
- name: Build and push image to Azure Container Registry
run: |
#!/usr/bin/env bash
# Versoin one
oc get $(oc api-resources --namspaced=true | tail -n+2 | awk '{ print $1 }' | xargs | sed -e 's/\s/,/g')
# Version two (from https://access.redhat.com/solutions/4165791)
oc api-resources --verbs=list --namespaced -o name | xargs -n 1 oc get --show-kind --ignore-not-found -n $PROJECT_NAME
@hemanth22
hemanth22 / retrieved-deployment-basic-ocp-demo.yaml
Created July 16, 2022 13:07 — forked from FreedomBen/retrieved-deployment-basic-ocp-demo.yaml
Deployment read back from OpenShift API with `oc get deployment basic-ocp-demo -o yaml`
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"labels":{"app":"basic-ocp-demo"},"name":"basic-ocp-demo","namespace":"basic-ocp-demo-project"},"spec":{"replicas":1,"selector":{"matchLabels":{"app":"basic-ocp-demo"}},"template":{"metadata":{"labels":{"app":"basic-ocp-demo"}},"spec":{"containers":[{"env":[{"name":"BASIC_OCP_DEMO_ENV","value":"master"}],"image":"quay.io/freedomben/basic-ocp-demo:latest","imagePullPolicy":"Always","name":"basic-ocp-demo","ports":[{"containerPort":4567,"protocol":"TCP"}],"readinessProbe":{"httpGet":{"path":"/healthz","port":4567,"scheme":"HTTP"},"initialDelaySeconds":5,"periodSeconds":1}}]}}}}
creationTimestamp: "2021-01-08T02:09:21Z"
generation: 1
labels:
curl -k "https://basic-ocp-demo-basic-ocp-demo-project.apps.cluster1.example.com/healthz"
# or build the curl URL programmatically!
curl -k "https://$(oc get route basic-ocp-demo -o jsonpath="{.spec.host}")/healthz"
@hemanth22
hemanth22 / get-fluentd-running
Created December 4, 2021 13:47 — forked from portante/get-fluentd-running
A script to help get fluentd pods running on all labeled nodes of an OpenShift cluster; we need this because Kube currently does not support priority or preemption which we could use to ensure fluentd are always scheduled and run on properly labeled nodes.
#!/bin/bash
function finish {
rm -rf $TMPDIR
}
trap finish EXIT
TMPDIR=$(mktemp -d)
oc get nodes -o name > $TMPDIR/all-nodes
oc get nodes -o name -l logging-infra-fluentd=true > $TMPDIR/labeled-nodes
@hemanth22
hemanth22 / kubectl
Created December 4, 2021 13:47 — forked from Nurlan199206/kubectl
Kubernetes команды примеры
kubernetes commands
kubectl config view - посмотреть к какому кластеру подключен kubectl (API IP:PORT)
kubectl get pods && kubectl get services --all-namespaces
kubectl get nodes - список нодов
kubectl exec -it postgres-57f4746d96-7z5q8 -- psql -U username databasename - подключиться к psql
@hemanth22
hemanth22 / 02-sa.sh
Created December 4, 2021 13:46 — forked from vfarcic/02-sa.sh
cd k8s-specs
# Only if minishift
oc apply -f sa/jenkins-no-sa-oc.yml --record
# Only if NOT minishift
kubectl apply \
-f sa/jenkins-no-sa.yml \
--record
@hemanth22
hemanth22 / pods-stuck-in-terminating
Created December 4, 2021 13:46 — forked from ikurni/pods-stuck-in-terminating
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
###Creating a template
oc login <YOUR_MINISHIFT_URL>
oc login -u system:admin
oc create -f <YOUR_YAML_FILE>.yaml -n openshift
###View/Edit template
oc edit template <YOUR_TEMPLATE> -n openshift
###View all templates available
oc get templates -n openshift