Skip to content

Instantly share code, notes, and snippets.

@mountkin
mountkin / cluster_controller.go
Created January 24, 2021 13:51
kubebuilder example
/*
Copyright 2021.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
#!/bin/bash
yum install -y lvm2
pvcreate /dev/sdc
vgcreate docker /dev/sdc
lvcreate --wipesignatures y -n thinpool docker -l 95%VG
lvcreate --wipesignatures y -n thinpoolmeta docker -l 1%VG
lvconvert -y --zero n -c 512K --thinpool docker/thinpool --poolmetadata docker/thinpoolmeta
cat<<-EOS>/etc/lvm/profile/docker-thinpool.profile
activation {
package main
import (
"fmt"
"sync"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
package main
import (
"time"
"github.com/docker/docker/pkg/pubsub"
)
func main() {
pub := pubsub.NewPublisher(0, 1)

Docker 2015年度回顾

Docker从2013年开源,到目前已经经历了三年的不断完善与优化。2015年是Docker开源项目突飞猛进的一年, 在这一年时间里,Docker先后发布了1.5, 1.6, 1.7, 1.8, 1.9 5个大版以及7个修订版。

功能上增加了只读容器、ulimit支持、日志驱动、Volume插件、网络插件、IPAM插件等新特性,更加适合企业多样化的应用场景; user namespace的支持也合并进了1.9实验版,这使得Docker的安全性得到大大提升。

Docker registry 2(github上的distribution项目)的发布,让镜像更加标准化,镜像的传输更加高效; 新增了镜像签名验证机制,保证了镜像传输的安全。

// Must start docker daemon with -H tcp://127.0.0.1:2375
package main
import (
"fmt"
"io"
"net/http"
"os"
"os/exec"
"strings"
goroutine 3102 [running]:
runtime/pprof.writeGoroutineStacks(0x7fb50589f070, 0xc208674320, 0x0, 0x0)
/usr/local/go/src/runtime/pprof/pprof.go:511 +0x8d
runtime/pprof.writeGoroutine(0x7fb50589f070, 0xc208674320, 0x2, 0x0, 0x0)
/usr/local/go/src/runtime/pprof/pprof.go:500 +0x4f
runtime/pprof.(*Profile).WriteTo(0x186ebc0, 0x7fb50589f070, 0xc208674320, 0x2, 0x0, 0x0)
/usr/local/go/src/runtime/pprof/pprof.go:229 +0xd5
net/http/pprof.handler.ServeHTTP(0x1103eb0, 0x9, 0x7fb50589f038, 0xc208674320, 0xc2086f4000)
/usr/local/go/src/net/http/pprof/pprof.go:169 +0x35f
net/http/pprof.(*handler).ServeHTTP(0xc20813e580, 0x7fb50589f038, 0xc208674320, 0xc2086f4000)
#!/bin/sh
set -e
trap 'echo -ne "\e[0m"' EXIT
export PATH=$PATH:/usr/local/bin
if ps h -p $$ -o args=''|cut -f1 -d' '|grep -q bash; then
set -o pipefail
elif [ -x /bin/bash ]; then
exec /bin/bash $0
fi
DOCKER_CMD=
@mountkin
mountkin / php-redis.spec
Created March 10, 2015 05:13
PHP redis extension RPM spec demo.
Name: php-redis
Version: 2.2.7
Release: 1%{?dist}
Summary: PHP pecl redis
Group: cSphere.cn/demo
License: PHP License 3.0
URL: http://pecl.php.net/redis
Source0: http://pecl.php.net/get/redis-2.2.7.tgz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
@mountkin
mountkin / go-bindata-and-gzip.go
Created January 19, 2015 08:43
Hack on go-bindata to support gzip Content-Encoding
package views
import (
"bytes"
"compress/gzip"
"io"
"mime"
"net/http"
"path"
"strings"