Skip to content

Instantly share code, notes, and snippets.

@ypan887
ypan887 / helm-cheatsheet.md
Created January 15, 2020 21:49 — forked from tuannvm/cka.md
#Helm #Kubernetes #cheatsheet, happy helming!
kind: Service # When service objects is created it will be assigned an internal cluster ip
apiVersion: v1
metadata:
name: my-service # When a service with selector is crated, an Endpoints object with the same name is
spec: # also created. Endpoints is a collection of endpoints that implement the actual
selector: # service. It is updated when service are added/removed
app: MyApp # Selectors to identify the backing pods
env: Pord
ports:
- protocol: TCP # Default potocal is TCP
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
template:
metadata:
labels: # label will be applied to each pod, label key need to be unique
app: nginx
apiVersion: apps/v1
kind: ReplicationController | ReplicaSet | Deployment # different controller
====================================================
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
@ypan887
ypan887 / deployment.yaml
Created March 13, 2019 17:45
example deployment object yaml
apiVersion: extensions/v1beta1 # Api Version
kind: Deployment # Object Type
metadata: # Metadata about this object
name: artifactory-test # Name of this deployment
spec: # Specification of this deployment
replicas: 1 # Number of replication
template: # Template used to create replica
metadata: # Metadata about the pods
labels: # labels used to identify the pods
app: artifactory-pro-standalone # label 'app'
var hashMap = {
Set : function(key,value){this[key] = value},
Get : function(key){return this[key]},
Contains : function(key){return this.Get(key) == null?false:true},
Remove : function(key){delete this[key]}
}
// to avoid collision in key, try to use unique string as key. If we want to handle key value other than string, or some two different key
// that result the same with toString, wo can roll our own hash method, to turn different type input into different key string
// or, We can use ES6 Map
function height(node){
if(!node) return 0;
var leftHeight = height(node.left);
var rightHeight = height(node.right);
return Math.max(leftHeight, rightHeight) + 1;
}
@ypan887
ypan887 / gist:63b6adb4e329c9b99c52357abb531257
Last active March 21, 2017 00:40
return form input as object
var form1 = document.getElementById('foo-bar').elements;
var form2 = document.getElementById('foo-bar-baz-qux').elements;
function getObject(inputs){
var cur = {}
for(var i=0;i<inputs.length; i++){
var names = inputs[i].name.split('.');
var temp = cur;
for(var j=0; j < names.length; j++){
var quickSort = function(arr) {
  if (arr.length <= 1) { return arr; }
  var pivotIndex = Math.floor(arr.length / 2);
  var pivot = arr.splice(pivotIndex, 1)[0];
  var left = [];
  var right = [];
  for (var i = 0; i < arr.length; i++){
    if (arr[i] < pivot) {
      left.push(arr[i]);
    } else {
@ypan887
ypan887 / gist:6669335828ada41bb744292ac01dfe5f
Created March 18, 2017 01:08
qucik select in place JS
function quickSelectInPlace(arr, k) {
if (!arr || arr.length <= k) {
throw 'Invalid input';
}
var len = arr.length;
var from = 0;
var to = len - 1;
while (from < to) {
var left = from;