Skip to content

Instantly share code, notes, and snippets.

View FreedomBen's full-sized avatar
💭
Currently setting my status

Ben Porter FreedomBen

💭
Currently setting my status
View GitHub Profile
@FreedomBen
FreedomBen / resource-quota-example.yaml
Created November 10, 2020 20:50
Example ResourceQuota object for an OpenShift namespace
- apiVersion: v1
kind: ResourceQuota
metadata:
name: ${PROJECT_NAME}-quota
spec:
hard:
pods: "10"
requests.cpu: "4"
requests.memory: 8Gi
limits.cpu: "6"
@FreedomBen
FreedomBen / new-project-template-with-limit-range-and-resource-quota.yaml
Created November 10, 2020 20:53
Complete new project template for OpenShift, with LimitRange and ResourceQuota
apiVersion: template.openshift.io/v1
kind: Template
metadata:
creationTimestamp: null
name: project-request
namespace: openshift-config
objects:
- apiVersion: project.openshift.io/v1
kind: Project
metadata:
@FreedomBen
FreedomBen / patch-cluster-project-config.bash
Created November 10, 2020 21:12
Set project request template name to "project-request"
$ oc patch project.config.openshift.io/cluster \
--type=merge \
-p '{"spec":{"projectRequestTemplate":{"name":"project-request"}}}'
$ oc new-project test-new-stuff
Now using project "test-new-stuff" on server "https://example.com:6443".
You can add applications to this project with the 'new-app' command. For example, try:
oc new-app ruby~https://github.com/sclorg/ruby-ex.git
to build a new example application in Ruby. Or use kubectl to deploy a simple Kubernetes application:
kubectl create deployment hello-node --image=gcr.io/hello-minikube-zero-install/hello-node
$ oc project
Using project "test-new-stuff" on server "https://example.com"
$ oc get limitrange
NAME CREATED AT
$ oc get project.config.openshift.io cluster -o=jsonpath='{.spec.projectRequestTemplate.name}'
project-request # should say "project-request" unless you customized it
@FreedomBen
FreedomBen / cb.sh
Created November 22, 2020 15:21
Add to .bashrc file to get `cb` command for clipboard
# A shortcut function that simplifies usage of xclip.
# - Accepts input from either stdin (pipe), or params.
# Retrieved from: http://madebynathan.com/2011/10/04/a-nicer-way-to-use-xclip/
# ------------------------------------------------
cb() {
local _scs_col="\e[0;32m"; local _wrn_col='\e[1;31m'; local _trn_col='\e[0;33m'
# Check that xclip is installed.
if ! type xclip > /dev/null 2>&1; then
echo -e "$_wrn_col""You must have the 'xclip' program installed.\e[0m"
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: application-nginx
name: application-nginx
spec:
replicas: 1
selector:
matchLabels:
spec:
containers:
- image: quay.io/<username>/nginx:latest
name: application-nginx
imagePullPolicy: Always
ports:
- containerPort: 8443
protocol: TCP
readinessProbe:
httpGet:
spec:
containers:
- image: quay.io/<username>/my-application-jobs:latest
name: my-application-jobs
imagePullPolicy: Always
livenessProbe:
exec:
command:
- /bin/sh
- -c
livenessProbe:
exec:
command:
- /bin/sh
- -c
- "[ -f /run/my-application-web.pid ] && ps -A | grep my-application-web"
initialDelaySeconds: 10
periodSeconds: 5