Sep 29, 2018
1 min read
Create function index.js
exports.handler = async function(event, context) { console.log("ENVIRONMENT VARIABLES\n" + JSON.stringify(process.env, null, 2)) console.log("EVENT\n" + JSON.stringify(event, null, 2)) return context.logStreamName } 打包
zip function.zip index.js aws lambda create-function --function-name my-function --zip-file fileb://function.zip --handler index.handler --runtime nodejs10.x --role arn:aws:iam::123456789012:role/lambda-cli-role --endpoint-url=http://localhost:4574 aws lambda get-function --function-name my-function --endpoint-url=http://localhost:4574 { "Code": { "Location": "http://localhost:4574/2015-03-31/functions/my-function/code" }, "Configuration": { "TracingConfig": { "Mode": "PassThrough" }, "Version": "$LATEST", "CodeSha256": "3d149vplmMjIEgZuPhQgnFJ+tndL4I9D11GL1qdgT6M=", "FunctionName": "my-function", "LastModified": "2019-09-29T01:16:43.
Sep 26, 2018
1 min read
在windows,启动卷必须线启用共享驱动
启用共享驱动
1: Open "Settings" in Docker Desktop ->
"Shared Drives" ->
"Reset Credentials" ->
select drive "D" -> "Apply"
检查测试卷
docker run --rm -v d:/tmp:/data alpine ls /data
Sep 26, 2018
2 min read
安装AWS CLI
(venv) d:\code\venv>pip install awscli pip install awscli-local awslocal = aws –endpoint-url=http://localhost:
可以安装到系统环境
配置AWS CLI
(venv) d:\code\venv>aws configure AWS Access Key ID [None]: any-id-is-ok AWS Secret Access Key [None]: fake-key Default region name [local]: local Default output format [None]: 命令行自动完成
$which aws_completer ~/code/venv/bin/aws_completer tee ~/.bashrc <<-'EOF' complete -C '~/code/venv/bin/aws_completer' aws EOF 安装AWS SAM CLI
(venv) d:\code>pip install aws-sam-cli (venv) d:\code>sam --version SAM CLI, version 0.
Sep 3, 2018
3 min read
bind eip gatsby develop -- --host=0.0.0.0 Prettier VS Code plugin JSX The hybrid “HTML-in-JS” is actually a syntax extension
of JavaScript, for React, called JSX
In pure JavaScript, it looks more like this:
src/pages/index.js
import React from "react" export default () => React.createElement("div", null, "Hello world!") Now you can spot the use of the ‘react’ import! But wait. You’re writing JSX, not pure HTML and
JavaScript. How does the browser read that?
Aug 29, 2018
1 min read
glide
To upgrade dependencies, please make the necessary modifications in glide.yaml and run glide update.
Jul 23, 2018
1 min read
Add notification configuration to SNS Topic resource "aws_sns_topic" "topic" { name = "s3-event-notification-topic" policy = <<POLICY { "Version":"2012-10-17", "Statement":[{ "Effect": "Allow", "Principal": {"AWS":"*"}, "Action": "SNS:Publish", "Resource": "arn:aws:sns:*:*:s3-event-notification-topic", "Condition":{ "ArnLike":{"aws:SourceArn":"${aws_s3_bucket.bucket.arn}"} } }] } POLICY } resource "aws_s3_bucket" "bucket" { bucket = "your_bucket_name" } resource "aws_s3_bucket_notification" "bucket_notification" { bucket = "${aws_s3_bucket.bucket.id}" topic { topic_arn = "${aws_sns_topic.topic.arn}" events = ["s3:ObjectCreated:*"] filter_suffix = ".log" } } Add notification configuration to Lambda Function resource "aws_iam_role" "iam_for_lambda" { name = "iam_for_lambda" assume_role_policy = <<EOF { "Version": "2012-10-17", "Statement": [ { "Action": "sts:AssumeRole", "Principal": { "Service": "lambda.
Jun 11, 2018
1 min read
ML2插件 ML2插件允许openstack网络中同时使用多种二层的网络技术;不同的节点可以使用不同的网络机制
ML2能够与现在所有的代理无缝集成;以前使用的代理无需变更,只要将传统的core plugin替换ML2
ML2使得对新的网络技术支持更为简单;无需重新开发新的core plugin插件;只需开发相应的机制驱动
ML2对二层的网络进行抽象;解锁了neutron所支持的网络类型(type)与访问这些网络类型的虚拟网络实现机制(mechansim);并通过驱动的形式进行扩展
不同的网络类型对应不同的类型驱动(type driver);由类型管理器(type manager)进行管理
不同的网络实现机制对应不同的机制驱动(mechansim);由机制管理器(mechansim manager)进行管理
neutron 支持的每一种网络类型都有一个对应的ML2类型驱动
类型驱动负责维护网络类型的状态;执行验证、创建网络等工作
目前neutron已经实现的网络类型包括:flat、local、vlan、vxlan、gre
目前neutron已经实现的网络机制有三种类型:
基于代理(agent-based): 包括linux bridge、open vswitch 基于控制器(controller-based): 包括open daylight、vmwavre NSX等 基于物理交换: 包括cisco nexus、arista、mellanox等 Mechanism drivers and L2 agents Mechanism Driver L2 agent Open vSwitch Open vSwitch agent Linux bridge Linux bridge agent SRIOV SRIOV nic switch agent MacVTap MacVTap agent linux bridge 代理 linux bridge 是成熟可靠的neutron二层网络虚拟化技术,支持local、flat、vlan、vxlan这四种网络类型,目前不支持gre
Jun 10, 2018
4 min read
删除 systemctl list-unit-files --all | grep yunion systemctl disable yunion-executor systemctl disable yunion-registry systemctl disable kubelet rm -rf /opt/yunion systemctl disable libvirtd.service ip link set virbr0 down brctl delbr virbr0 operator kubectl logs -n onecloud default-region- -c init kubectl edit deployments. -n onecloud onecloud-operator containers: - command: - /bin/onecloud-controller-manager - -sync-user onecloud-operator,加上‘-sync-user’ 会自动修改用户密码, 然后再 kubectl delete deployments -n onecloud default-region 等待重建再试试
WEB 前端代码是很多 git 仓库组成的,需要用 ‘yarn sync release/3.
Jun 4, 2018
1 min read
避开Tiller使用Helm部署K8S应用
Tiller存在的问题 破坏RBAC访问机制 全局的Tiller拥有cluster-admin角色,所以在安装过程中,服务以cluster-admin 角色可以越权访问资源
部署名字不能重复且唯一 部署名字唯一且很多chart中部署名字也添加到服务名中,导致服务名字混乱。
独立使用helm 获取模板 使用配置修改模板 生产yaml文件
git clone https://github.com/istio/istio.git cd istio git checkout 1.0.6 -b 1.0.6 helm template install/kubernetes/helm/istio --name istio --namespace istio-system \ --set security.enabled=false \ --set ingress.enabled=false \ --set gateways.istio-ingressgateway.enabled=false \ --set gateways.istio-egressgateway.enabled=false \ --set galley.enabled=false \ --set sidecarInjectorWebhook.enabled=false \ --set mixer.enabled=false \ --set prometheus.enabled=false \ --set global.proxy.envoyStatsd.enabled=false \ --set pilot.sidecar=false > $HOME/istio-minimal.yaml kubectl create namespace istio-system kubectl apply -f $HOME/istio-minimal.
May 20, 2018
2 min read
Container When working with cloud native solutions such as Kubernetes, resources are volatile. Services come and go by design, and that’s fine—as long as the whole system operates in a regular way. Classical monitoring solutions aren’t always able to handle this transience gracefully
Graphite Graphite has no direct data collection support. Carbon listens passively for data, but in order to enable data collection, you should include solutions like fluentd, statd, collectd, or others in your time series data pipeline.
May 10, 2018
1 min read
Headless services Without POD selectors This creates a service, but it doesn’t know where to send the traffic. This allows you to manually create an Endpoints object that will receive traffic from this service.
kind: Endpoints apiVersion: v1 metadata: name: mongo subsets: - addresses: - ip: 10.240.0.4 ports: - port: 2701 CNAME records for ExternalName This service does a simple CNAME redirection at the kernel level, so there is very minimal impact on performance.
May 5, 2018
2 min read
INSTALL docker
docker run -d --name=netdata \ -p 19999:19999 \ -v /etc/passwd:/host/etc/passwd:ro \ -v /etc/group:/host/etc/group:ro \ -v /proc:/host/proc:ro \ -v /sys:/host/sys:ro \ -v /etc/os-release:/host/etc/os-release:ro \ --cap-add SYS_PTRACE \ --security-opt apparmor=unconfined \ netdata/netdata script
bash <(curl -Ss https://my-netdata.io/kickstart.sh) --stable-channel --disable-telemetry Attempting another netdata start using command 'systemctl start netdata' [/tmp/netdata-kickstart-uytL3g/netdata-v1.21.1]# systemctl start netdata OK OK netdata started! Downloading default configuration from netdata... [/tmp/netdata-kickstart-uytL3g/netdata-v1.21.1]# curl -sSL --connect-timeout 10 --retry 3 http://localhost:19999/netdata.
May 2, 2018
1 min read
物联网架构
An IoT Architecture consists of the following:
- Peripherals, which we call “things”.
- Sensors attached to these things to gauge and transmit their data and information.
- Network connection through which data is transmitted (wireless or wired).
- Remote Cloud to which data is transmitted by the system.
物联网核心构件
Sensors
Microcontrollers
Gateways
Applications
物联网分层架构
May 1, 2018
1 min read
The most important conversation you ever have is the one with yourself
Apr 30, 2018
1 min read
典型无服务器架构应用场景
应用后台
数据处理
实时分析
遗留应用API代理
调度服务
RPA
最新实现参考
Apr 29, 2018
1 min read
https://stackoverflow.com/questions/44547574/create-api-gateway-in-localstack/48682628
https://github.com/localstack/localstack/issues/632
AWS SAM is an extension for the AWS CloudFormation template language that lets you define serverless
applications at a higher level
localstack default regrion
us-east-1
create stack
file path has to be in file URL format(file:///home/user/…)
func.yaml
AWSTemplateFormatVersion: '2010-09-09'
Description: Simple CloudFormation Test Template
Resources:
S3Bucket:
Type: AWS::S3::Bucket
Properties:
AccessControl: PublicRead
BucketName: test-bucket-1
aws cloudformation create-stack --stack-name funstack --template-body file:///data/func.yaml --endpoint-url=http://localhost:4581 --region us-east-1
aws cloudformation describe-stacks --endpoint-url=http://localhost:4581 --region us-east-1
Apr 28, 2018
1 min read
docker proxy
run cmd as administrator
cmd>cd $GIT_HOME
cmd>echo > .bash_profile
export HTTP_PROXY=http://127.0.0.1:1080
export HTTPS_PROXY=http://127.0.0.1:1080
export no_proxy=localhost,127.0.0.1,192.168.99.100