yaml 角色群集

roles
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: promtail-clusterrole
rules:
- apiGroups: [""]
  resources: ["nodes", "services", "pods"]
  verbs: ["get", "watch", "list"]

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: promtail-clusterrolebinding
subjects:
- kind: ServiceAccount
  name: promtail
  namespace: default
roleRef:
  kind: ClusterRole
  name: promtail-clusterrole
  apiGroup: rbac.authorization.k8s.io

yaml 部署Kubernetes

deployment
# [START Deployment]
---
apiVersion: "extensions/v1beta1"
kind: "Deployment"
metadata:
  name: "pr-efact"
  namespace: "efact"
  labels:
    app: "pr-efact"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: "pr-efact"
  template:
    metadata:
      labels:
        app: "pr-efact"
    spec:
      containers:
      - name: "pr-efact"
        image: "us.gcr.io/nutresa-prod/ns_3405_send_file_efact:71"
        env:
          - name: "NODE_ENV"
            valueFrom:
              configMapKeyRef:
                name: "pr-efactdata"
                key: "NODE_ENV"
          - name: "HTTPS"
            valueFrom:
              configMapKeyRef:
                name: "pr-efactdata"
                key: "HTTPS"
          - name: "URL_PO"
            valueFrom:
              configMapKeyRef:
                name: "pr-efactdata"
                key: "URL_PO"
          - name: "URL_TOKEN_EFACT"
            valueFrom:
              configMapKeyRef:
                name: "pr-efactdata"
                key: "URL_TOKEN_EFACT"
          - name: "URL_FILE_EFACT"
            valueFrom:
              configMapKeyRef:
                name: "pr-efactdata"
                key: "URL_FILE_EFACT"
          - name: "URL_CONFIRM_RESPONSE_EFACT"
            valueFrom:
              configMapKeyRef:
                name: "pr-efactdata"
                key: "URL_CONFIRM_RESPONSE_EFACT"
          - name: "USER_PO"
            valueFrom:
              secretKeyRef:
                name: "pr-efactsecrets"
                key: "USER_PO"
          - name: "PASS_PO"
            valueFrom:
              secretKeyRef:
                name: "pr-efactsecrets"
                key: "PASS_PO"
          - name: "USER_TOKEN_EFACT"
            valueFrom:
              secretKeyRef:
                name: "pr-efactsecrets"
                key: "USER_TOKEN_EFACT"
          - name: "PASS_TOKEN_EFACT"
            valueFrom:
              secretKeyRef:
                name: "pr-efactsecrets"
                key: "PASS_TOKEN_EFACT"        
          - name: "PATH_SSL_CERTIFICATE_KEY"
            valueFrom:
              secretKeyRef:
                name: "pr-efactsecrets"
                key: "PATH_SSL_CERTIFICATE_KEY"
          - name: "PATH_SSL_CERTIFICATE_CERT"
            valueFrom:
              secretKeyRef:
                name: "pr-efactsecrets"
                key: "PATH_SSL_CERTIFICATE_CERT"
          - name: "PATH_SSL_CERTIFICATE_CA"
            valueFrom:
              secretKeyRef:
                name: "pr-efactsecrets"
                key: "PATH_SSL_CERTIFICATE_CA"
        ports:
        - containerPort: 443
          protocol: TCP
        resources:
          limits:
            cpu: 1.5
            memory: 4096Mi
          requests:
            cpu: 0.5
            memory: 1500Mi

---
apiVersion: "autoscaling/v1"
kind: "HorizontalPodAutoscaler"
metadata:
  name: "laravel-hpa"
  namespace: "efact"
  labels:
    app: "pr-efact"
spec:
  scaleTargetRef:
    kind: "Deployment"
    name: "pr-efact"
    apiVersion: "apps/v1beta1"
  minReplicas: 1
  maxReplicas: 2
  targetCPUUtilizationPercentage: 80
# [END Deployment]

yaml Azure管道

Azure管道

azure-pipelines.yml
# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/java

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: Maven@3
  inputs:
    mavenPomFile: 'pom.xml'
    options: '-Dbuild.artifactId=$(artifactId) -Dbuild.artifactVersion=$(Build.BuildNumber) -DfunctionAppName=$(functionAppName)'
    mavenOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    publishJUnitResults: false
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
    goals: 'package'
- task: CopyFiles@2
  displayName: Copy Files
  inputs:
    SourceFolder: $(System.DefaultWorkingDirectory)/target/azure-functions/
    Contents: '**'
    TargetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
  displayName: Publish Artifact
  inputs:
    PathtoPublish: $(Build.ArtifactStagingDirectory)

yaml Python:Linting,Formatting和Testing

使用现代工具设置python项目

README.md
# Python: Linting, Formatting, and Testing

After much experience, this is the list of modern tooling for python projects.

## Linting

### Flake8

[flake8](http://flake8.pycqa.org) does fast single-file linting with
plugins for rules.

Add to project with these plugins:

```
poetry add -D flake8 flake8-bugbear flake8-logging-format \
  flake8-pep3101 flake8-builtins flake8-comprehensions \
  flake8-string-format flake8-eradicate flake8-mutable \
  flake8-pytest flake8-mock flake8-docstrings \
  flake8-variables-names pep8-naming
```

Add a `.flake8` configuration file containing this base configuration:

```
[flake8]
ignore = D203,D103,E722
exclude =
    .git,
    __pycache__,
    docs/source/conf.py,
    old,
    build,
    dist
max-complexity = 10
max-line-length = 88
no-isort-config = true
use-varnames-strict-mode = true
```

### MyPy

[mypy](http://mypy-lang.org/) does type checking and important linting even
when not using type annotations.

Add to the project:

```
poetry add -D mypy
```

Add a `mypy.ini` configuration file with this configuration:

```
# Global options:

[mypy]
python_version = 3.7
ignore_missing_imports = True
follow_imports = silent
show_column_numbers = True
warn_unused_configs = True
disallow_subclassing_any = True
disallow_any_generics = True
disallow_untyped_calls = False
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
disallow_untyped_decorators = True
no_implicit_optional = True
warn_redundant_casts = True
warn_unused_ignores = True
warn_return_any = True

# Per-module options:

## In this section, add overrides for specific files, modules, or functions
## that don't yet have type annotations. For example:
##  [mypy-older_module.older_file]
##  disallow_untyped_defs = False
```

### Bandit

[bandit](https://github.com/PyCQA/bandit) finds common security issues
in Python code.

Add to the project:

```
poetry add -D bandit
```

Create a `.bandit` configuration file:

```
[bandit]
exclude: tests/
```

Bandit doesn't seem to use the configuration file by default, so you'll
need to execute it like this: `bandit --ini .bandit -r *`

## Formatting

### Black

[black](https://github.com/python/black) is an
"uncompromising Python code formatter".

Add to the project:

```
poetry add -D --allow-prereleases black 
```

`--allow-prereleases` is necessary because at the time of this writing Black
does not have a stable release yet.

### isort

[isort](https://github.com/timothycrosley/isort) sorts and lints the imports at
the top of a python file.

Add to the project:

```
poetry add -D isort toml
```

Add the following to `pyproject.toml`.
This configuration is compatible with Black.

```
[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
line_length = 88
known_first_party = []
known_third_party = []
```

## Testing

[pytest](https://docs.pytest.org/en/latest/) is a modern test framework that
supports fixtures and parameterization. It can be used with
`unittest.mock` for mocks, stubs, and spies.

Add to the project with these plugins:

```
poetry add -D pytest pytest-mock pytest-cov pytest-env pytest-sugar
```

See also the `pytest-xdist` plugin if concurrent testing is desired.

Create a `pytest.ini` configuration file as needed. There is no recommended
default configuration.

Create a `/tests` directory and add test files with file names that start with
`test_`, for example `test_something.py` where 'something' is the file, module,
or functionality under test.

## VSCode

To activate the above capabilities in VSCode, add the following settings to
`.vscode/settings.json` in your project directory:

```
{
  "python.pythonPath": ".venv/bin/python",
  "files.exclude": {
    "**/__pycache__": true
  },
  "editor.codeActionsOnSave": {
    "source.organizeImports": true
  },
  "python.testing.unittestEnabled": false,
  "python.testing.nosetestsEnabled": false,
  "python.testing.pytestEnabled": true,
  "python.testing.pytestArgs": ["--no-cov"],
  "python.linting.enabled": true,
  "python.linting.pylintEnabled": false,
  "python.linting.banditEnabled": true,
  "python.linting.flake8Enabled": true,
  "python.linting.flake8CategorySeverity.E": "Warning",
  "python.linting.mypyEnabled": true,
  "python.formatting.provider": "black",
  "editor.formatOnSave": true
}
```

Also, add the `rope` library to the project to allow for VSCode to refactor
python files:

```
poetry add -D rope
```

## EditorConfig

Create a `.editorconfig` file in the root of the project:

```
[*]
indent_style = space

[*.{py}]
indent_size = 4

[*.{sh}]
indent_size = 2
```

## Pre-commit

Enforce the above rules on every commit
using [pre-commit](https://pre-commit.com/).

Add to the project:

```
poetry add -D pre-commit
poetry run pre-commit install
```

Add the attached `.pre-commit-config.yaml` file to the root of the project.

## Tox

I haven't extensively tested Tox yet, but here's what I have so far in
a `tox.ini` file:

```
[tox]
isolated_build = true
envlist = py37

[testenv]
whitelist_externals = poetry
# passenv per https://pre-commit.com/#usage-with-tox
passenv = SSH_AUTH_SOCK http_proxy https_proxy no_proxy
commands =
    poetry install -v
    poetry run pytest tests/
```

## Further Reading

Python Code Quality: Tools & Best Practices
https://realpython.com/python-code-quality/
.pre-commit-config.yaml
repos:
  - repo: https://github.com/asottile/seed-isort-config
    rev: 'v1.9.1'
    hooks:
      - id: seed-isort-config
  - repo: https://github.com/timothycrosley/isort
    rev: '4.3.21-2'
    hooks:
      - id: isort
        types: [python]
        additional_dependencies: ['toml']
  - repo: https://github.com/python/black
    rev: stable
    hooks:
      - id: black
        language_version: python3.7
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: 'v0.711'
    hooks:
      - id: mypy
  - repo: https://gitlab.com/pycqa/flake8
    rev: '3.7.7'
    hooks:
      - id: flake8
  - repo: https://github.com/PyCQA/bandit
    rev: '1.6.2'
    hooks:
      - id: bandit
        args: ['--ini', '.bandit']
        types: [python]

yaml app.yml

app.yml
version: '2'
services:
    ciencia-app:
        image: danimaniarqsoft/ciencia:0.0.1
        environment:
            - SPRING_PROFILES_ACTIVE=prod,swagger
            - SPRING_DATA_MONGODB_URI=mongodb://ciencia-mongodb:27017
            - SPRING_DATA_MONGODB_DATABASE=ciencia
            - APP_SLEEP=10 # gives time for the database to boot before the application
        ports:
            - 8080:8080
    ciencia-mongodb:
        image: mongo:3.4.10
        ports:
            - "27017:27017"

yaml 要搜索的单词

要搜索的单词

dictionary-spec.yaml
 /v1/dictionary:
    get:
      tags:
        - 'Query Dictionary'
      parameters:
        - name: word
          in: query
          required: true
          description: Word to search
          schema:
            type: string
          example: happy
        - name: pageNo
          in: query
          required: true
          description: Page Number
          schema:
            type: integer
          example: 1
      responses:
        '200':
          description: 'Success'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResult'
              example:
                startPage: 1
                endPage: 2
                totalRecords: 100
                currentPage: 1
                words:
                  - id: 1
                    word: Abarticulation
                    meaning: Articulation, usually that kind of articulation which admits of free motion in the joint; diarthrosis.
                  - id: 2
                    word: Abase
                    meaning: To cast down or reduce low or lower, as in rank, office, condition in life, or estimation of worthiness; to depress; to humble; to degrade.
        '404':
          description: 'Word not found'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
              example:
                message: 'No matching words found'
                path: '/v1/dictionary?word=zzzzz&pageNo=1'
components:
    SearchResult:
      type: 'object'
      properties:
        startPage:
          type: 'integer'
          description: 'Start page number'
        endPage:
          type: 'integer'
          description: 'End page number'
        totalRecords:
          type: 'integer'
          description: 'Records per page'
        currentPage:
          type: 'integer'
          description: 'Current page number'
        words:
          type: 'array'
          items:
            $ref: '#/components/schemas/Meaning'

    Meaning:
      type: 'object'
      properties:
        id:
          type: 'integer'
          description: 'Word ID'
        word:
          type: 'string'
          description: 'Word'
        meaning:
          type: 'string'
          description: 'Meaning of the word'

    ErrorMessage:
      type: 'object'
      properties:
        message:
          type: 'string'
          description: 'Description of the error'
        path:
          type: 'string'
          description: 'Identity of the resource'

yaml 在页面中获取文字

在页面中获取文字

dictionary-spec.yaml
  /v1/dictionary/page/{pageNo}:
    get:
      tags:
        - 'Query Dictionary'
      parameters:
        - name: pageNo
          in: path
          required: true
          description: Page number of the dictionary
          schema:
            type: integer
            format: int64
            minimum: 1
          example: 1
      responses:
        '200':
          description: 'Success'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Dictionary'
              example:
                currentPage: 1
                words:
                  - id: 1
                    word: Abarticulation
                    meaning: Articulation, usually that kind of articulation which admits of free motion in the joint; diarthrosis.
                  - id: 2
                    word: Abase
                    meaning: To cast down or reduce low or lower, as in rank, office, condition in life, or estimation of worthiness; to depress; to humble; to degrade.
        '404':
          description: 'Requested page not found'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
              example:
                message: 'Page not found'
                path: '/v1/dictionary/page/4'
        '500':
          description: 'Internal server error'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
              example:
                message: 'An error has occurred'
                path: '/v1/dictionary/page/4'

components:
    Dictionary:
      type: 'object'
      properties:
        currentPage:
          type: 'integer'
          description: 'Current page number'
        words:
          type: 'array'
          items:
            $ref: '#/components/schemas/Meaning'
            
    Meaning:
      type: 'object'
      properties:
        id:
          type: 'integer'
          description: 'Word ID'
        word:
          type: 'string'
          description: 'Word'
        meaning:
          type: 'string'
          description: 'Meaning of the word'

    ErrorMessage:
      type: 'object'
      properties:
        message:
          type: 'string'
          description: 'Description of the error'
        path:
          type: 'string'
          description: 'Identity of the resource'

yaml 获取总页数规范

获取总页数规范

dictionary-spec.yaml
  /v1/dictionary/pages:
    get:
      tags:
        - 'Query Dictionary'
      responses:
        '200':
          description: 'Success'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Page'
              example:
                start: 1
                end: 3
                recordsPerPage: 10
        '500':
          description: 'Internal server error'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
              example:
                message: 'An error has occurred'
                path: '/v1/dictionary/pages'

components:
  schemas:
    Page:
      type: 'object'
      properties:
        start:
          type: 'integer'
          description: 'Start page number'
        end:
          type: 'integer'
          description: 'End page number'
        recordsPerPage:
          type: 'integer'
          description: 'Records per page'

    ErrorMessage:
      type: 'object'
      properties:
        message:
          type: 'string'
          description: 'Description of the error'
        path:
          type: 'string'
          description: 'Identity of the resource'

yaml 泊坞窗,compose_wordpress.yml

docker-compose_wordpress.yml
version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       WORDPRESS_DB_NAME: wordpress
volumes:
    db_data: {}

yaml docker_compose_rabbitmq.yml

docker_compose_rabbitmq.yml
rabbitmq:
  image: rabbitmq:management
  ports:
    - "5672:5672"
    - "15672:15672"