microsoft / mssql-docker

Official Microsoft repository for SQL Server in Docker resources
MIT License
1.72k stars 759 forks source link

apply imagePullSecrets to sqlserver image on azure container registry: line, xx found character that cannot start any token #321

Open logcorner opened 6 years ago

logcorner commented 6 years ago

Hi, I have added some test data on sql server image and pushed it to a azure container registry.

Now I would like to deploy the given image to kubernetes , so i must add an imagePullSecrets to kubernetes deployment file. but I have an identation error : line, xx found character that cannot start any token.

How to fix it ? here is my files

docker-compose file

version: '3'

services:
  frontend:
    image: frontend
    build:
      context: .
      dockerfile: frontend/Dockerfile
    depends_on:
      - api
  api:
    image: api
    build:
      context: .
      dockerfile: Api/Dockerfile
    depends_on: 
      - sqlserver
  sqlserver:
    image: sqlserver
    expose:
      - "1433"
    build:
      context: ./SqlServer
      dockerfile: Dockerfile
    volumes:
      - /var/opt/mssql
      # we copy our scripts onto the container
      - ./sql:/usr/src/app 
    # bash will be executed from that path, our scripts folder
    working_dir: /usr/src/app 
    # run the entrypoint.sh that will import the data AND sqlserver
    command: sed -i -e 's/\r$//' entrypoint.sh
    command: sh -c ' chmod +x ./entrypoint.sh; ./entrypoint.sh & /opt/mssql/bin/sqlservr;'
    environment:
      ACCEPT_EULA: Y
      SA_PASSWORD: P@55w0rd

./SqlServer/DokerFile

FROM microsoft/mssql-server-linux:latest

app-kubernetes-sqlserver.yaml

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: kubernetes-sqlserver-deployment
  labels:
    app: kubernetes
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: kubernetes
        tier: sqlserver
    spec:
      containers:
      - name: sqlserver
        image: microsoft/mssql-server-linux:latest
        ports:
        - containerPort: 1433
        env:
        - name: SA_PASSWORD
          value: "Testing1122"
        - name: ACCEPT_EULA
          value: "Y"
     imagePullSecrets:
        - name: regsecret
---
apiVersion: v1
kind: Service
metadata:
  name: kubernetes-sqlserver-service
spec:
  ports:
  - name: sqlserver
    port: 1433
    targetPort: 1433
  selector:
    app: kubernetes
    tier: sqlserver
  type: LoadBalancer

regards

twright-msft commented 6 years ago

@logcorner - I would suggest using a combination of tools like VS Code to help you format .yaml files correctly and using linting tools to help you find out what is wrong with your format.

Here is a good YAML linter: http://www.yamllint.com/

The indentation is off.

Bad: image

Good: image