小编seb*_*ian的帖子

如何使用附加功能和版本说明符 pip install -e ?

使用时:

pip install -e pip-package
Run Code Online (Sandbox Code Playgroud)

如何做相当于:

pip install pip-package[all]==1.10.0
Run Code Online (Sandbox Code Playgroud)

“[all]”是我试图利用的额外功能。

python pip

8
推荐指数
1
解决办法
2051
查看次数

使用 Kustomize 替换列表中项目的内容

我在尝试使用 kustomize 来替换列表中项目的内容时遇到困难。

我的自定义文件

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - resource.yaml

patches:
  - patch.yaml

Run Code Online (Sandbox Code Playgroud)

我的 patch.yaml 文件

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-service
spec:
  template:
    spec:
      initContainers:
        - name: web-service-migration
          env:
            - name: PG_DATABASE
              value: web-pgdb


Run Code Online (Sandbox Code Playgroud)

我的资源.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-service
spec:
  template:
    spec:
      initContainers:
        - name: web-service-migration
          env:
            - name: PG_DATABASE
              valueFrom:
                secretKeyRef:
                  name: web-pgdb
                  key: database


Run Code Online (Sandbox Code Playgroud)

自定义构建返回

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-service
spec:
  template:
    spec:
      initContainers:
      - env:
        - name: PG_DATABASE
          value: …
Run Code Online (Sandbox Code Playgroud)

kubernetes kustomize

8
推荐指数
1
解决办法
4677
查看次数

terraform 缺少资源实例密钥

我不确定我做错了什么。我有这样的地形:

resource "aws_apigatewayv2_domain_name" "web" {
  domain_name = var.web_url
  count       = var.web_url != "" ? 1 : 0

  domain_name_configuration {
    certificate_arn = var.web_acm_arn
    endpoint_type   = "REGIONAL"
    security_policy = "TLS_1_2"
  }
}

resource "aws_apigatewayv2_api_mapping" "web" {
  api_id      = aws_apigatewayv2_api.web.id
  domain_name = aws_apigatewayv2_domain_name.web.id
  stage       = aws_apigatewayv2_stage.web_stage.id
  count       = var.web_url != "" ? 1 : 0
}
Run Code Online (Sandbox Code Playgroud)

我的地形计划返回了这个。它抱怨计数,但不确定如何处理它。


Terraform v0.12.24
Configuring remote state backend...
Initializing Terraform configuration...
2020/07/29 06:20:46 [DEBUG] Using modified User-Agent: Terraform/0.12.24 TFC/29e17ad841


Error: Missing resource instance key

  on ../modules/web/api.tf line 37, …
Run Code Online (Sandbox Code Playgroud)

terraform

7
推荐指数
1
解决办法
3593
查看次数

与其他账户共享 AWS 托管 KMS 密钥

我有一个 s3 文件夹,其中包含加密的对象。它使用 AWS KMS 托管密钥而不是自定义密钥进行加密。我需要另一个 AWS 账户才能从此存储桶复制文件。据我所知,我无法跨帐户共享此 KMS 密钥。我也无法轻松更改此存储桶以使用自定义密钥,因为这会对客户产生影响。这里有什么好的解决办法吗?

amazon-web-services amazon-kms

7
推荐指数
1
解决办法
6789
查看次数

Terraform aws_api_gateway_integration_response 一直想改变属性

Terraform aws_api_gateway_integration_response 一直想更改 selection_pattern 属性。任何指导将不胜感激。


resource "aws_api_gateway_integration_response" "api_gateway_integration_response_e1_default" {
  rest_api_id       = "${aws_api_gateway_rest_api.api_gateway_rest_api.id}"
  resource_id       = "${aws_api_gateway_resource.e1_api_gateway_resource.id}"
  http_method       = "${aws_api_gateway_method.e1_api_gateway_method.http_method}"
  status_code       = "${aws_api_gateway_method_response.api_gateway_method_response_e1_202.status_code}"
  selection_pattern = "-"
}

resource "aws_api_gateway_integration_response" "api_gateway_integration_response_e2_default" {
  rest_api_id       = "${aws_api_gateway_rest_api.api_gateway_rest_api.id}"
  resource_id       = "${aws_api_gateway_resource.e2_api_gateway_resource.id}"
  http_method       = "${aws_api_gateway_method.e2_api_gateway_method.http_method}"
  status_code       = "${aws_api_gateway_method_response.api_gateway_method_response_e2_202.status_code}"
  selection_pattern = "-"
}
Run Code Online (Sandbox Code Playgroud)

我的 terraform 应用输出一直想要更新。

terraform apply
...
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  ~ module.gateway.aws_api_gateway_integration_response.api_gateway_integration_response_e1_default …
Run Code Online (Sandbox Code Playgroud)

terraform

6
推荐指数
1
解决办法
583
查看次数

jq - 在键名中转义反斜杠

我有一个带有 \ 的密钥,但我似乎无法使用 jq 访问它。任何帮助表示赞赏。

$ cat /tmp/yo
{
  "kubectl.kubernetes.io\last-applied-configuration": "test"
}

$ cat /tmp/yo | jq .["kubectl.kubernetes.io\last-applied-configuration"]
parse error: Invalid escape at line 2, column 52
Run Code Online (Sandbox Code Playgroud)

linux jq

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

Apache Airflow - 用户管理和多租户

我正在尝试创建一个可以托管多个用户的 Apache Airflow 实例,并且不会对彼此产生负面影响。这包括但不限于:

  • 维护自己的python环境
  • 管理自己的变量
  • 管理自己的连接
  • 管理自己的DAG

查看官方气流文档。我看到一些可能有帮助的事情。

1) 创建用户的能力和 2) 多租户的能力。

1)如果我遵循用户创建过程https://airflow.apache.org/security.html#web-authentication。创建的所有用户似乎都是管理员,但如何创建非管理员用户并控制他们可以做什么/不能做什么?我似乎无法找到更多文档。

2)链接https://airflow.apache.org/security.html#multi-tenancy说“当通过设置打开身份验证时,您可以按所有者名称过滤网络服务器中的 dags 列表”,但我不知道不知道如何将 dags 分配给特定用户。

谢谢您的帮助。

airflow

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

气流 dags 和 PYTHONPATH

我有一些 dags 似乎无法找到 python 模块。在 Airflow UI 内部,我看到了大量这些消息变化。

Broken DAG: [/home/airflow/source/airflow/dags/test.py] No module named 'paramiko'

在文件内部,我可以直接修改 python sys.path,这似乎减轻了我的问题。 import sys sys.path.append('/home/airflow/.local/lib/python2.7/site-packages')

尽管必须直接在我的代码中设置我的路径,但这感觉不对。我已经尝试在 Airflow 用户帐户 .bashrc 中导出 PYTHONPATH,但在执行 dag 作业时似乎没有被读取。解决这个问题的正确方法是什么?

谢谢。

- - - 更新 - - -

感谢您的回复。

下面是我的 systemctl 脚本。

::::::::::::::
airflow-scheduler-airflow2.service
::::::::::::::
[Unit]
Description=Airflow scheduler daemon

[Service]
EnvironmentFile=/usr/local/airflow/instances/airflow2/etc/envars
User=airflow2
Group=airflow2
Type=simple
ExecStart=/usr/local/airflow/instances/airflow2/venv/bin/airflow scheduler
Restart=always
RestartSec=5s

[Install]
WantedBy=multi-user.target
::::::::::::::
airflow-webserver-airflow2.service
::::::::::::::
[Unit]
Description=Airflow webserver daemon

[Service]
EnvironmentFile=/usr/local/airflow/instances/airflow2/etc/envars
User=airflow2
Group=airflow2
Type=simple
ExecStart=/usr/local/airflow/instances/airflow2/venv/bin/airflow webserver
Restart=always
RestartSec=5s

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

这是 EnvironentFile Contents …

airflow airflow-scheduler

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

AWS IAM s3:前缀

我在 Terraform 中有一个 AWS IAM 策略,其编写方式如下:

            {
                "Effect": "Allow",
                "Action": [
                    "s3:ListBucket"
                ],
                "Resource": "arn:aws:s3:::bucket-name",
                "Condition": {
                    "StringLike": {
                        "s3:prefix": "${local.account_id}/*"
                    }
                }
            }
Run Code Online (Sandbox Code Playgroud)

但是,我试图理解为什么使用 s3:prefix 。这不能通过以下方式完成:

            {
                "Effect": "Allow",
                "Action": [
                    "s3:ListBucket"
                ],
                "Resource": "arn:aws:s3:::bucket-name/${local.account_id}/*",
            }
Run Code Online (Sandbox Code Playgroud)

amazon-web-services amazon-iam terraform

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

在启动之前等待另一个模块完成的 terraform 模块

我正在寻找一种解决方法,因为模块不能依赖于其他模块。

我相信这就是您应该如何创建一个模块,该模块在启动之前等待另一个模块完成。但是,我发现这对我仍然不起作用。我的设置方式有什么问题吗?

有了这个,我仍然看到 module2 中的资源被构建,不依赖于其他任何东西。

module "module1" {
    source = "./module1"
}

module "module2" {
    source = "./module2"
    somevar = "${module.module1.somevar}"
}

./module1/outputs.tf

output "somevar" {
  value = "nothing"
}


./module2/variables.tf

variable "somevar" {}
Run Code Online (Sandbox Code Playgroud)

非常感谢。

terraform

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

Terraform条件-如果变量不存在

我有以下情况:

resource "aws_elastic_beanstalk_application" "service" {
  appversion_lifecycle {
    service_role          = "service-role"
    delete_source_from_s3 = "${var.env == "production" ?   false : true}"
  }
}
Run Code Online (Sandbox Code Playgroud)

如果var.env设置为生产,我会得到想要的结果。

谢谢!

但是,如果未定义var.env,则terraform计划将失败,因为从未定义该变量。我如何才能使它工作而不必定义该变量?

terraform

3
推荐指数
3
解决办法
3288
查看次数

Terraform 在索引处导入资源

我的 terraform 正在尝试创建以下 s3 存储桶资源。

  # module.storage.module.s3_bucket[14].aws_s3_bucket.this[0] will be created
  + resource "aws_s3_bucket" "this" {
      + acceleration_status         = (known after apply)
      + acl                         = "private"
      + arn                         = (known after apply)
      + bucket                      = "assets-bucket"
      + bucket_domain_name          = (known after apply)
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = false
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)
      + website_domain              = (known after …
Run Code Online (Sandbox Code Playgroud)

terraform

3
推荐指数
1
解决办法
3524
查看次数