小编Tib*_*. M的帖子

如何从外部连接到 Kubernetes 中的无头服务?

我创建了一个无头服务:

apiVersion: v1
kind: Service
metadata:
  name: myapp-service-headless
spec:
  ports:
    - port: 80
  selector:
    app: myapp
  clusterIP: None
Run Code Online (Sandbox Code Playgroud)

从 Kubernetes 仪表板我可以看到它Internal endpoints

myapp-service-headless:80 TCP
myapp-service-headless:0 TCP
Run Code Online (Sandbox Code Playgroud)

在此应用程序中,我还将内部端点设置为:

http://myapp-service-headless
Run Code Online (Sandbox Code Playgroud)

但是从外部如何访问其IP来连接API呢?

比如我的Kubernetes的IP是192.168.99.100,那么连接192.168.99.100可以吗?

现在来自 Kubernetes 仪表板的服务状态

服务

在此输入图像描述

服务详情

在此输入图像描述

ip internals cluster-computing endpoint kubernetes

5
推荐指数
1
解决办法
9484
查看次数

如何为预签名 URL 设置 minio 域?

我在 Kubernetes 中使用 minio,效果很好。但是,我似乎无法更改预签名 URL 的域和协议。Minio 总是给我http://minio.test.svc:9000/delivery/想要的地方https://example.com/delivery。我尝试MINIO_DOMIN在pod中设置,但似乎没有效果;无论如何,我认为我滥用了这个变量。

kubernetes minio

5
推荐指数
1
解决办法
1万
查看次数

如何检查用户是否订阅了特定的 Telegram 频道(Python / PyTelegramBotApi)?

我正在使用PyTelegramBotApi 库编写一个Telegram 机器人,我想实现检查用户对某个电报频道的订阅的功能,如果没有,则提供订阅。预先感谢您的回答!

python bots telegram telegram-bot py-telegram-bot-api

5
推荐指数
1
解决办法
1万
查看次数

通过 pyTelegramBotAPI 和 pythonanywhere.com 上的 Flask 使用 Telegram bot webhook

问题是关于使用 pyTelegramBotAPI 模块在 Telegram 机器人中使用 webhook。我正在使用 pythonanywhere.com 来托管机器人。

下面的代码工作正常:

from flask import Flask, request
import telebot

secret = "A_SECRET_NUMBER"
bot = telebot.TeleBot ('YOUR_AUTHORIZATION_TOKEN')
bot.set_webhook("https://YOUR_PYTHONANYWHERE_USERNAME.pythonanywhere.c..
}".format(secret), max_connections=1)

app = Flask(__name__)
@app.route('/{}'.format(secret), methods=["POST"])
def telegram_webhook():
   update = request.get_json()
   if "message" in update:
   text = update["message"]["text"]
   chat_id = update["message"]["chat"]["id"]
   bot.sendMessage(chat_id, "From the web: you said '{}'".format(text))
return "OK"
Run Code Online (Sandbox Code Playgroud)

但是,当我使用示例中所示的消息处理程序时,我没有收到机器人的答复:

# Process webhook calls
@app.route(WEBHOOK_URL_PATH, methods=['POST'])
def webhook():
   if flask.request.headers.get('content-type') == 'application/json':
   json_string = flask.request.get_data().decode('utf-8')
   update = telebot.types.Update.de_json(json_string)
   bot.process_new_updates([update])
   return ''
else:
   flask.abort(403) …
Run Code Online (Sandbox Code Playgroud)

flask pythonanywhere telegram telegram-bot py-telegram-bot-api

4
推荐指数
1
解决办法
5469
查看次数

通过 pyTelegramBotAPI 在电报机器人中获取照片

我正在尝试开发一个简单的机器人,它可以从用户那里检索照片,然后对媒体文件进行多项操作。我正在使用 Telebot ( https://github.com/eternnoir/pyTelegramBotAPI ) 进行设计。

就我从 wiki 上看到的而言,我可以通过content_type使用特殊处理程序来划分收入消息。

但是,当我写了这么简单的方法时:

#main.py
@bot.message_handler(content_types= ["photo"])
def verifyUser(message):
    print ("Got photo")
    percent = userFace.verify(message.photo, config.photoToCompare)
    bot.send_message(message.chat.id, "Percentage: " + str(percent))

def getData(json_string):
    updates = telebot.types.Update.de_json(json_string)
    bot.process_new_updates([updates])


#server.py
app = Flask(__name__)

@app.route("/", methods=["POST", "GET"])
def hello():
    json_string = request.get_data()
    getData(json_string)
    print("....")
    print(request.data)
    return 'test is runing'

if __name__ == '__main__':
    app.run(host='0.0.0.0')
Run Code Online (Sandbox Code Playgroud)

我遇到了这样的错误,我无法归类是我做错了什么还是 API 有问题

obj = cls.check_json(json_type)
File "/usr/local/lib/python2.7/dist-packages/telebot/types.py", line 77, in check_json
return json.loads(json_type)
File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
return …
Run Code Online (Sandbox Code Playgroud)

python python-2.7 telegram-bot py-telegram-bot-api

4
推荐指数
2
解决办法
1万
查看次数

有没有办法从 kuberentes 环境中的 pod 下载容器镜像?

有没有办法从 kuberentes pod 下载容器镜像?假设我们有多个容器在一个 Pod 中运行,我们想要下载容器,以便我们可以在该容器中离线做一些事情。我们想直接从 Kubernetes pod 下载的原因是因为大多数环境设置已经设置并且容器应该能够以单个 docker 命令启动。

这就像从 kubernetes pod 环境中询问 docker compose 文件。

kubernetes docker-compose

4
推荐指数
1
解决办法
2432
查看次数

线程“main”org.apache.spark.SparkException 中的异常:必须指定驱动程序容器映像

我正在尝试使用命令从本地机器 CLI 在 minikube(Kubernetes) 上执行 spark-submit

spark-submit --master k8s://https://127.0.0.1:8001 --name cfe2 
--deploy-mode cluster --class com.yyy.Test --conf spark.executor.instances=2 --conf spark.kubernetes.container.image docker.io/anantpukale/spark_app:1.1 local://spark-0.0.1-SNAPSHOT.jar
Run Code Online (Sandbox Code Playgroud)

我有一个基于 verison 2.3.0 的简单火花作业 jar。我还在 docker 和 minikube 中将它容器化并在虚拟机上运行。以下是异常堆栈:

Exception in thread "main" org.apache.spark.SparkException: Must specify the driver container image at org.apache.spark.deploy.k8s.submit.steps.BasicDriverConfigurationStep$$anonfun$3.apply(BasicDriverConfigurationStep.scala:51) at org.apache.spark.deploy.k8s.submit.steps.BasicDriverConfigurationStep$$anonfun$3.apply(BasicDriverConfigurationStep.scala:51) at scala.Option.getOrElse(Option.scala:121)  at org.apache.spark.deploy.k8s.submit.steps.BasicDriverConfigurationStep.<init>(BasicDriverConfigurationStep.scala:51)
        at org.apache.spark.deploy.k8s.submit.DriverConfigOrchestrator.getAllConfigurationSteps(DriverConfigOrchestrator.scala:82)
        at org.apache.spark.deploy.k8s.submit.KubernetesClientApplication$$anonfun$run$5.apply(KubernetesClientApplication.scala:229)
        at org.apache.spark.deploy.k8s.submit.KubernetesClientApplication$$anonfun$run$5.apply(KubernetesClientApplication.scala:227)
        at org.apache.spark.util.Utils$.tryWithResource(Utils.scala:2585)
        at org.apache.spark.deploy.k8s.submit.KubernetesClientApplication.run(KubernetesClientApplication.scala:227)
        at org.apache.spark.deploy.k8s.submit.KubernetesClientApplication.start(KubernetesClientApplication.scala:192)
        at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:879)
      at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:197)
        at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:227)
        at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:136)
        at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala) 2018-04-06 13:33:52 INFO  ShutdownHookManager:54 - Shutdown hook called 2018-04-06 …
Run Code Online (Sandbox Code Playgroud)

docker apache-spark kubernetes kubectl minikube

4
推荐指数
1
解决办法
3213
查看次数

在同一个 kubernetes 集群上安装两个 traefik 入口控制器

我有一种情况,我计划在 Kubernetes 集群内使用两个单独的 traefik 入口控制器。

我有一些 URL,我希望只能通过 VPN 访问,而很少有一些 URL 可以公开访问。

在当前的架构中,我有一个 traefik-ingress 控制器和两个独立的 ALB,一个内部的,一个面向互联网的,都指向 traefik。
假设我有一个 URLpublic.example.comprivate.example.com. public.example.com指向面向互联网的 ALB,private.example.com指向内部 ALB。但是,如果有人知道 的指向public.example.com并指向private.example.com他的相同指向/etc/hosts,他将能够访问我的私人网站。

为了避免这种情况,我计划运行两个单独的 traefik-ingress-controller,一个仅提供私有 URL 和一个公共 URL。这可以做到吗?或者有没有其他方法可以避免这种情况

security kubernetes traefik kubernetes-ingress traefik-ingress

4
推荐指数
1
解决办法
5387
查看次数

如何在python 3.7中安装pyramid-arima

我正在尝试在 Windows10 上的 python 3.7 中实现 auto arima 所以我尝试使用以下命令安装 Pyramid-armia

pip install pyramid-arima
Run Code Online (Sandbox Code Playgroud)

但我收到错误消息

 Could not find a version that satisfies the requirement pyramid-arima (from versions: )]
 No matching distribution found for pyramid-arima
Run Code Online (Sandbox Code Playgroud)

我也尝试过这里提到的步骤

但收到了同样的错误消息,您能指导我安装吗?

python forecast

4
推荐指数
1
解决办法
8153
查看次数

Python、 Telethon 发送专辑

好久都没法写剧本了。我有一个电报频道,我不想从该频道重新发送专辑,而是通过一条消息将其发送给我

from telethon import TelegramClient, events
from telethon import events

api_id = 
api_hash = ""

chat = ''

client = TelegramClient('', api_id, api_hash)

print('started')

@client.on(events.Album)
async def handler(event):
 #what farther
Run Code Online (Sandbox Code Playgroud)

python telethon

4
推荐指数
1
解决办法
2482
查看次数