public static String format(String format, Object... args) {
return new Formatter().format(format, args).toString();
}
public static boolean hasDebugFlag() {
String path = Environment.getExternalStorageDirectory() + "/Log/debug"; //文件路径
FileWriter writer = null;
try {
File file = new File(path);
return file.exists();
}catch (Exception e) {
}
return false;
}
public static void removeDebugFlag() {
String path = Environment.getExternalStorageDirectory() + "/Log/debug"; //文件路径
FileWriter writer = null;
try {
File file = new File(path);
if(file.exists()) {
file.delete();
}
}catch (Exception e) {
}
}
public static void writeLog(String fileName,String content) {
String path = Environment.getExternalStorageDirectory() + "/Log/"; //文件路径
FileWriter writer = null;
try {
File file = new File(path);
if (!file.exists()) { //没有创建文件夹则创建
file.mkdirs();
}
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(currentTime);
// 打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件
writer = new FileWriter(path + fileName, true);
writer.write(dateString + " " + content + "\r\n");
writer.flush();
if (writer != null) {
//关闭流
writer.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
public static boolean saveBitmap(Bitmap bitmap, Long id) {
if (bitmap == null)
return false;
String path = Environment.getExternalStorageDirectory() + "/Log/";
FileOutputStream fos = null;
try {
File f = new File(path +id.toString() + ".png");
if(f.exists()) {
f.delete();
}
f.createNewFile();
fos = new FileOutputStream(f);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.flush();
return true;
} catch (Exception e) {
e.printStackTrace();
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return false;
}
public void dumpFrame(ImiDevice.ImiFrame nextFrame, Long id) {
try{
ByteBuffer frameData = nextFrame.getData();
int width = nextFrame.getWidth();
int height = nextFrame.getHeight();
frameData.position(0);
int length = frameData.remaining();
byte[] buf = new byte[length];
frameData.get(buf);
Bitmap save = com.commaai.face.util.Utils.RGB2Bitmap(buf, width, height);
saveBitmap(save, id);
}catch (Exception e) {
writeLog("brokenflow.txt", "failed to save bitmap");
}
}
使用逻辑
if(hasDebugFlag()) {
dumpcnt = 20;
removeDebugFlag();
}
if(dumpcnt > 0) {
dumpcnt--;
total++;
dumpFrame(nextFrame, total);
}
作者归档:xinlu
VNC的安装
服务端安装:
yum -y install tigervnc-server
启动服务,直接执行,然后按提示输入访问密码。
vncserver
istio的sidecar注入原理
博文:https://zhaohuabing.com/2018/05/23/istio-auto-injection-with-webhook/
从k8s 1.9版本以来,引入AdmissionWebhook扩展机制,允许对ApiServer创建资源的进行验证及修改。
从图中看到,Admission中有两个重要的阶段,Mutation和Validation,这两个阶段中执行的逻辑如下:
Mutation
Mutation是英文“突变”的意思,从字面上可以知道在Mutation阶段可以对请求内容进行修改。
Validation
在Validation阶段不允许修改请求内容,但可以根据请求的内容判断是继续执行该请求还是拒绝该请求。
通过Admission webhook,可以加入Mutation和Validation两种类型的webhook插件,这些插件和Kubernets提供的预编译的Admission插件具有相同的能力。可以想到的用途包括:
修改资源。例如Istio就通过Admin Webhook在Pod资源中增加了Envoy sidecar容器。
自定义校验逻辑,例如对资源名称有一些特殊要求。或者对自定义资源的合法性进行校验。
Android安卓sshserver服务器版
Android/lto物联网等
第一种方案是Libssh2/libssh1这两种方案,需要个人开发很多功能。
第二种使用已经安卓化的应用:https://github.com/CFM880/simplesshd,可搭配
http://www.galexander.org/software/simplesshd/
https://gitee.com/skyuning/frpc-Android安卓的反向代理。
https://github.com/fatedier/frp
https://github.com/FrpcCluster/frpc-Android安卓的集群版反向代理
ISTIO的版本依赖
ISTIO的版本支持情况。
公司支持的版本是K8S-1.15.7和ISTIO-1.6
https://istio.io/latest/docs/setup/platform-setup/
Istio 1.6 has been tested with these Kubernetes releases: 1.15,1.16, 1.17, 1.18
docker-compose的陷阱
docker-compose如果不配置network属性,则会创建一个新的子网,而这个子网的网段极有可能与某个内网网段发生冲突。
所以最好在docker-compose.yml中增加network属性配置。
docker-compose启动服务的过程包括以下过程:
第一步创建子网网桥。可以通过”ip route”获取到相关子网IP。
第二步按服务依赖启动服务
{
"bip":"192.168.55.1/24"
}
networks:
default:
driver: bridge
driver_opts:
com.docker.network.enable_ipv6: "false"
ipam:
driver: default
config:
- subnet: 192.168.56.0/24
MQTT
MQTT服务器非常多,如apache的ActiveMQ,emtqqd,HiveMQ,Emitter,Mosquitto,Moquette等等。
使用容器Mosquitto的MQTT实现。
mosquitto_sub -t ‘test/topic’ -c -i id -q 1
mosquitto_pub -t ‘test/topic’ -m ‘hello world23334’ -q 1
mosquitto_sub -t ‘test/topic’ -c -i id -q 1 -u abc -P 123
mosquitto_pub -t ‘test/topic’ -m ‘hello world23334’ -q 1 -u abc -P 123
confluence的破解版
https://github.com/joker8023/confluence
https://blog.csdn.net/weixin_41381248/article/details/80409567
https://blog.csdn.net/sltin/article/details/95491176
k8s的几种快捷安装方式
内置ISTIO的kubeSphere,100%开源。
KubeOperator另一个K8s开源。
https://gitee.com/q7104475/K8s:更简单的方式
1.https://github.com/easzlab/kubeasz,以Ansible工具进行远程安装。
2.https://github.com/fanux/sealos,离线安装
3.kuboard.cn的教程安装
4.rancher管理工具内自带安装引导。
5.基于kubespray工具安装,因为防火墙的原因,需要修改为国内镜像源。
https://blog.csdn.net/forezp/article/details/82730382
https://blog.csdn.net/zhouzixin053/article/details/104418164
其它参考:
https://github.com/kelseyhightower/kubernetes-the-hard-way
https://github.com/opsnull/follow-me-install-kubernetes-cluster
枚举问题POD及输出其问题
1.获取当前所有的命名空间
kubectl get ns
2.遍历命名空间,检查非Running状态的容器如ImagePullBackOff/ContainerCreating等,如下。
kubectl get pods -n kube-system
[root@k8smaster ~]# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
calico-kube-controllers-5b8b769fcd-lsjt4 1/1 Running 2 6d3h
calico-node-6l6r4 1/1 Running 2 6d2h
calico-node-gt95n 1/1 Running 2 6d3h
coredns-546565776c-4bn2d 1/1 Running 2 6d3h
coredns-546565776c-cwpk7 1/1 Running 2 6d3h
etcd-k8smaster 1/1 Running 2 6d3h
kube-apiserver-k8smaster 1/1 Running 3 6d3h
kube-controller-manager-k8smaster 1/1 Running 2 6d3h
kube-proxy-7s8dw 1/1 Running 2 6d2h
kube-proxy-cbgtv 1/1 Running 2 6d3h
kube-scheduler-k8smaster 1/1 Running 2 6d3h
kuboard-7bb89b4cc4-bk7d4 0/1 ContainerCreating 0 15m
metrics-server-7f96bbcc66-qjk5b 0/1 ContainerCreating 0 15m
3.获取问题POD的输出内容。
kubectl describe pod kuboard-7bb89b4cc4-bk7d4 --namespace=kube-system