Skip to content

Instantly share code, notes, and snippets.

View pruan-rht's full-sized avatar

Peter Ruan pruan-rht

  • Red Hat
  • Sunnvale, CA
View GitHub Profile
@pruan-rht
pruan-rht / .vimrc
Last active May 26, 2016 16:07
Peter's .vimrc
set nocompatible
set guioptions+=T
filetype off
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'Vundlevim/Vundle.vim'
@pruan-rht
pruan-rht / peter.vim
Created October 9, 2014 17:55
Peter's vim color
"
" Fruity Color Scheme
" ===================
"
" Author: Armin Ronacher <armin.ronacher@active-4.com>
" Version: 0.2
"
set background=dark
if version > 580
" no guarantees for version 5.8 and below, but this makes it stop
@pruan-rht
pruan-rht / gist:b0e75db164437d48d2d67d851fdb823a
Created May 25, 2016 18:19
using VIM Tabular to auto align tables
1. Install tabular VIM plugin
https://github.com/godlygeek/tabular
2. add the following to your .vimrc
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
#### checkout and use another user's branch
git remote add chancez git@github.com:chancez/operator-metering
git fetch chancez
git checkout -b hive_table_resource chancez/hive_table_resource
export METERING_CR_FILE=/home/pruan/junk/metering-pr655.yaml
export METERING_OPERATOR_IMAGE_REPO=quay.io/ecnahc515/origin-metering-helm-operator
export METERING_OPERATOR_IMAGE_TAG=rewrite2

My Openshift Cheatsheet

Openshift build secrets for cloning git repos using SSH Keys

  • To create ssh secret:
oc create secret generic sshsecret \
    --from-file=ssh-privatekey=$HOME/.ssh/id_rsa

My Openshift Cheatsheet

Openshift build secrets for cloning git repos using SSH Keys

  • To create ssh secret:
oc create secret generic sshsecret \
    --from-file=ssh-privatekey=$HOME/.ssh/id_rsa

Overview

To expediate the process of deploying Metering, you can create the requisite OLM custom resources locally, using the openshift client.

Prerequisites

  • Need an existing CatalogSource custom resource (e.g. qe-app-registry) that contains the metering-operator's manifest bundle.
  • Verify that there's a metering-ocp packagemanifest. Note: there's some naming collision with the qe-app-registry and redhat-operators packages, but you should be able to tell if there's no populated publisher field for the package.

Procedure

## OpenShift4 pull-secret:
1. Download your pull-secret from [openshift.com/try](https://cloud.redhat.com/openshift/install/aws/installer-provisioned)
- click on “Download Pull Secret”. Save it somewhere, e.g. ~/some-dir/pull-secret
2. Add the apps.ci auth to pull-secret! _internal OpenShift developers only_
- Obtain an API token by visiting https://oauth-openshift.apps.ci.l2s4.p1.openshiftapps.com/oauth/token/request
copy the oc login cmd and paste in terminal to login to the ci cluster, then run this:
- `$ oc registry login --to ~/some-dir/pull-secret`
This will append the auth from registry.ci.openshift.org to your cloud.openshift.com pull-secret but it will also
make the pull-secret multi-line.
In general when things are left over from failed installs or failed destroy cluster, you need to go through resource by resource and look for your partial label (e.g. mffiedler). Oftentimes deleting the VPC will reap child resources, but to be thorough, go through (in this order):
S3: S3 bucket - this can be difficult to find. There could be two (one starts terraform and one image-registry) - use install log or cluster creation time to find them
EC2: Instances
EC2: Load Balancers (also search on the VPC IOD for ELBs that show up - there are sometimes "hidden" ELBs in the same VPC)
VPC: NAT Gateways (Delete 1-by-1, they take time to actually delete and can old up subsequent deletes, keep refreshing)
VPC: After waiting you can try to delete the VPC itself but it will likely complain about interfaces in use
VPC: If the VPC did not delete clean you likely have to go to the security group it complains about, try to delete it and then delete any resources it thinks are in use
VPC: Security group - search by la