Skip to content

Instantly share code, notes, and snippets.

@tiewei
tiewei / kubebuilder_vs_operator-sdk.md
Created April 10, 2019 18:30
kubebuilder_vs_operator-sdk

kubebuilder vs operator-sdk

Abstract

kubebuilder and operator-sdk are two major tools used to set up a controller/operator code base for kubernetes CRDs. Both of them under the hood using controller-runtime to adding a manager, api scheme and creates an structs implements a reconciler interface, thus the major difference are around the tools for integration, testing and etc.

Backgroud

import uuid
from datetime import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, Boolean, Enum, ForeignKey, DateTime
TEMPLATE_ID = '00000000-0000-0000-0000-000000000003'
CREDENTIAL_ID = '00000000-0000-0000-0000-000000000001'
@tiewei
tiewei / align_tap_with_qvo.yml
Created March 3, 2016 08:55
hack_qvo_tap_ovs_tags
---
- hosts: tenant_compute*
gather_facts: no
tasks:
- shell: ovs-vsctl list-ports br-int | egrep "tap" | sed "s/^tap//"
register: qvo
- shell: ovs-vsctl get Port qvo{{item}} tag
with_items: qvo.stdout_lines
register: qvo_tags
@tiewei
tiewei / yaml_file.py
Created December 15, 2015 09:53
ansible yaml lookup
# This is a lookup for yaml file
# e.g /path/to/yaml/file
# ---
# foo: foo_value
# users:
# user_one: Jim
# user_two: Tom
#
# With inline lookup, the value of the key has to be a string
# 1. var1: "{{lookup('yaml_file', '/path/to/yaml/file key=foo')"
- What do Etcd, Consul, and Zookeeper do?
- Service Registration:
- Host, port number, and sometimes authentication credentials, protocols, versions
numbers, and/or environment details.
- Service Discovery:
- Ability for client application to query the central registry to learn of service location.
- Consistent and durable general-purpose K/V store across distributed system.
- Some solutions support this better than others.
- Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
- Centralized locking can be based on this K/V store.
@tiewei
tiewei / gerrit_repos_sync.sh
Last active August 29, 2015 13:56
gerrit_repos_sync
#! /bin/bash
gerrit_user='<user>'
gerrit_pass='<pass>'
gerrit_ip='<gerrit_ip>'
gerrit_port='8083'
gerrit_clone_port='29418'
backup_dir="/path/to/git_backup/dir"
@tiewei
tiewei / task_scheduler
Created January 3, 2014 07:43
A task timer based on rufus-scheduler, added logger and start/shutdown feature
require 'rufus-scheduler'
module Clipper
class TaskScheduler
def initialize(logger)
@scheduler = build_scheduler(logger)
@scheduled_tasks = []
@running = false