Posts

https://github.com/wubigo/localstack-examples

Listen Notes(以下简称LN)是一个iPod试听资料搜索引擎和数据库,

它使用的技术是非常过时的,没有AI,没有深度学习,

没有区块链。“如果有谁一定要说我在使用AI,那他一定没有

使用真正的AI”。

通过阅读本帖,你能完全复制一个Listen Notes和其他相似的网站。

你不需要雇佣很多工程师。是否还记得,当脸书以5700万美元收购

Instagram的时候,Instagram总共只有13名员工,包括非工程技术

人员。Instagram是在2012初成立的,现在是2019,云计算技术更加

成熟,站在巨人的肩膀上,一个规模较小的工程团队更有可能做出一

些有意义的产品,即使是像我这样的OPC(一个人独立成立的公司)。

我发现本帖已经在HN和reddit上被广泛分享,对此,我在这里做些

澄清:

  • 本帖并不是最新的。LN使用的技术栈在不停的演进,经过过去两年的

    全职的开发,技术开始变得有点复杂了。LN在2017年初启动的时候

    只用了3台VPS.这里所说的“过时”是指我只使用了我熟悉的技术来快速

    的开发产品,聚焦到业务侧

  • 现在我每天只花20%的时间在工程技术上,其他的时间都在进行业务沟通,

    回复邮件,每天不断总结思考

  • 如果因为没有使用你推荐的技术,或者没有回复你提出的问题,而冒犯了

    你的话,请你原谅。我不能做到让每个人都开心满意

  • 本帖只是告诉你做互联网产品的一种方法,但并不是唯一方法。而且它可能

    不是最好的方法。它通过使用数据手段帮你了解技术世界。

https://broadcast.listennotes.com/the-boring-technology-behind-listen-notes-56697c2e347b

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.

在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

安装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.

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?

glide

To upgrade dependencies, please make the necessary modifications in glide.yaml and run glide update.

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.

准备

  • 搭建测试环境

可以参考从源代码构件K8S开发环境

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

删除 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.

避开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.

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.

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.

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.

物联网架构

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

物联网分层架构

The most important conversation you ever have is the one with yourself

7 lvevel communication

典型无服务器架构应用场景

  • 应用后台

  • 数据处理

  • 实时分析

  • 遗留应用API代理

  • 调度服务

  • RPA

最新实现参考

https://www.freecodecamp.org/news/rest-is-the-new-soap-97ff6c09896d/

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