Skip to content

Instantly share code, notes, and snippets.

@victortsaitw12
victortsaitw12 / clusterrolebindings.yml
Created January 9, 2019 15:20 — forked from jimmycuadra/clusterrolebindings.yml
Default RBAC cluster roles and cluster role bindings built into Kubernetes
apiVersion: v1
items:
- apiVersion: rbac.authorization.k8s.io/v1alpha1
kind: ClusterRoleBinding
metadata:
creationTimestamp: 2017-02-23T00:03:51Z
name: cluster-admin
namespace: ""
resourceVersion: "35"
selfLink: /apis/rbac.authorization.k8s.io/v1alpha1/clusterrolebindingscluster-admin
'use strict'
const projectId = process.env.DF_PROJECT_ID;
const dialogflow = require('dialogflow');
const Users = require('./users.js');
const restRequest = require('./restRequest.js');
class AI {
constructor() {
console.log('dialogflow:project_id:' + projectId);
'use strict'
const express = require('express');
const Linebot = require('./linebot.js');
const app = express();
const linebot = new Linebot();
//const ai = new AI();
apiVersion: v1
kind: Service
metadata:
name: line-bot-service
spec:
type: NodePort
ports:
- name: http
port: 8100
targetPort: 8100
kind: Ingress
metadata:
name: fanout-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: -ip
ingress.kubernetes.io/rewrite-target: /
kubernetes.io/ingress.allow-http: "false"
spec:
tls:
- hosts:
metadata:
name: elasticsearch
spec:
serviceName: elasticsearch-service
replicas: 1
template:
metadata:
labels:
role: elasticsearch
spec:
function ElkfetchData(elasticsearch, coin_type) {
let query_body = {
"query": {
"function_score": {
"query": {
"multi_match": {
"query": coin_type,
"operator": "and",
"fields": ["title", "content"]
}
from jpy_currency.items import ArticleItem
from scrapy.utils.markup import remove_tags
class ArticleSpider(scrapy.Spider):
name = "articleSpider"
def start_requests(self):
print('start request currency news')
urls = ['news web site']
for url in urls:
def saveToELK(item):
if Utility.elk is None:
Utility.elk = Elasticsearch(hosts= 'elasticsearch')
# 檢查如果沒有這個 index 則新增
if Utility.elk.indices.exists(index='article') is not True:
res = Utility.elk.indices.create(index="article", body={
"mappings": {
"article": {
"properties": {
"title": {
public class WordCount {
public Topology createTopology(){
StreamsBuilder builder = new StreamsBuilder();
// 監聽 Kafka 裡 topic 為 word-count-input 收到的資料
KStream<String, String> textLines = builder.stream("word-count-input");
KTable<String, Long> wordCounts = textLines
// 查看收到的資料值
.peek((key, value) -> System.out.println(value))
// 資料值轉成小寫
.mapValues(textLine -> textLine.toLowerCase())