Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
I may be slow to respond.

zhangguanzhang zhangguanzhang

🎯
I may be slow to respond.
View GitHub Profile
View k8s_shell.sh
# 取无法拉取镜像名
kubectl get po `kubectl get pod -o wide | grep Image | awk '{print $1}'` -o yaml | grep -Po 'image: \K\S+' | sort -u
# docker save -o images.tar.gz \
imgList=""
while read img;do
if docker inspect $img &>/dev/null;then
imgList+="$imgList $img"
fi
View k8s_patch.sh
#!/bin/bash
# imagePullSecrets
kubectl -n kafka patch deployments kafka-0 -p '{"spec":{"template":{"spec":{"dnsConfig":{"options":[{"name":"single-request-reopen"}]}}}}}'
# dnsOptions
kubectl patch deploy $name \
-p '{"spec":{"template":{"spec":{"dnsConfig":{"options":{["name":"single-request-reopen"]}}}}}}'
# hostNetwork
View docker_pprof.md

离线环境来从现场获取docker的pprof信息步骤

获取go的镜像

while read img;
  do docker run --rm --entrypoint go $img version 2>/dev/null | grep -qw version && { echo $img;break; }; 
done < <(docker images --format '{{.Repository}}:{{.Tag}}')
View build docker-cli
scripts/build/.variables 文件去掉-w
scripts/build/binary 增加 -gcflags="all=-trimpath=$PWD -N -l"
构建 make -f docker.Makefile binary
@zhangguanzhang
zhangguanzhang / podman.txt
Last active Oct 2, 2020
podman compile on CentOS8
View podman.txt
dnf install -y gcc make wget vim git libseccomp-devel systemd-libs systemd-devel jq patch tar
go get github.com/go-delve/delve/cmd/dlv
make BUILDTAGS="containers_image_openpgp systemd exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper selinux seccomp " podman
podman system service --time 0 tcp:127.0.0.1:8081
curl http://localhost:8081/v1.40/containers/create?name=test-api2 -X POST \
-H "Content-Type: application/json" \
View rbac_casbin.go
package main
import (
"fmt"
"log"
"github.com/casbin/casbin/v2"
gormadapter "github.com/casbin/gorm-adapter/v2"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
@zhangguanzhang
zhangguanzhang / gist:791c484f6137f8deaed473a3857219ee
Last active May 17, 2020
golang Remove the specified repeated string
View gist:791c484f6137f8deaed473a3857219ee
package main
import (
"fmt"
)
func main() {
s := `aaabccaad`
u := "a"
fmt.Printf("%s %s ===> %s \n", s, u, uniq(s, u))
You can’t perform that action at this time.