proget 安装与使用

摘要:分别提下docker方式安装与yaml安装,如何与k8s体系结合使用,proget用于做nuget包管理以及镜像仓库。是自动化部署的一个环节。

docker安装方式

docker network create proget

[password]是sqlserver密码

docker run --name proget-sql \
      -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=[password]' \
      -e 'MSSQL_PID=Express' --net=proget --restart=unless-stopped \
      -d mcr.microsoft.com/mssql/server:2017-latest
docker exec -it proget-sql /opt/mssql-tools/bin/sqlcmd \
   -S localhost -U SA -P '[password]' \
   -Q 'CREATE DATABASE [ProGet] COLLATE SQL_Latin1_General_CP1_CI_AS'
docker run -d -v proget-packages:/var/proget/packages -p 80:80 \
    --link=proget-sql --net=proget \
    --name=proget --restart=unless-stopped -e PROGET_DB_TYPE=SqlServer \
    -e PROGET_DATABASE='Data Source=localhost; Initial Catalog=ProGet; User ID=sa; Password=[password]' \
    inedo/proget:latest

有免费版本的,需要
获取proget密钥

Kubernetes安装方式YAML

在rancher导入yaml或者自己看界面做一个都行,记得把[password]替换成自己的数据库密码

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
    field.cattle.io/creatorId: user-nsfrs
    field.cattle.io/publicEndpoints: '[{"addresses":["192.168.101.136"],"port":30323,"protocol":"TCP","serviceName":"basic:proget-nodeport","allNodes":true}]'
    kubectl.kubernetes.io/last-applied-configuration: '{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{"deployment.kubernetes.io/revision":"4","field.cattle.io/creatorId":"user-nsfrs","field.cattle.io/publicEndpoints":"[{\"addresses\":[\"192.168.3.36\"],\"port\":30323,\"protocol\":\"TCP\",\"serviceName\":\"basic:proget-nodeport\",\"allNodes\":true}]"},"creationTimestamp":"2019-12-06T09:20:45Z","generation":5,"labels":{"cattle.io/creator":"norman","workload.user.cattle.io/workloadselector":"deployment-basic-proget"},"name":"proget","namespace":"basic","resourceVersion":"21780","selfLink":"/apis/apps/v1/namespaces/basic/deployments/proget","uid":"001db8a6-f7e4-4d3f-80e4-565548dd8214"},"spec":{"progressDeadlineSeconds":600,"replicas":1,"revisionHistoryLimit":10,"selector":{"matchLabels":{"workload.user.cattle.io/workloadselector":"deployment-basic-proget"}},"strategy":{"rollingUpdate":{"maxSurge":1,"maxUnavailable":0},"type":"RollingUpdate"},"template":{"metadata":{"annotations":{"cattle.io/timestamp":"2019-12-06T09:26:24Z","field.cattle.io/ports":"[[{\"containerPort\":80,\"dnsName\":\"proget-nodeport\",\"kind\":\"NodePort\",\"name\":\"progetport\",\"protocol\":\"TCP\"}]]"},"creationTimestamp":null,"labels":{"workload.user.cattle.io/workloadselector":"deployment-basic-proget"}},"spec":{"containers":[{"env":[{"name":"PROGET_DATABASE","value":"Data
      Source=localhost; Initial Catalog=ProGet; User ID=sa; Password=[password]"},{"name":"PROGET_DB_TYPE","value":"SqlServer"}],"image":"inedo/proget:latest","imagePullPolicy":"Always","name":"proget","ports":[{"containerPort":80,"name":"progetport","protocol":"TCP"}],"resources":{},"securityContext":{"allowPrivilegeEscalation":false,"privileged":false,"readOnlyRootFilesystem":false,"runAsNonRoot":false},"stdin":true,"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","tty":true,"volumeMounts":[{"mountPath":"/var/proget/packages","name":"progetvol"}]},{"env":[{"name":"ACCEPT_EULA","value":"Y"},{"name":"MSSQL_PID","value":"Express"},{"name":"MSSQL_SA_PASSWORD","value":"[password]"}],"image":"mcr.microsoft.com/mssql/server:2017-latest","imagePullPolicy":"Always","name":"proget-sql","resources":{},"securityContext":{"allowPrivilegeEscalation":false,"capabilities":{},"privileged":false,"readOnlyRootFilesystem":false,"runAsNonRoot":false},"stdin":true,"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","tty":true,"volumeMounts":[{"mountPath":"/var/opt/mssql","name":"progetvol"}]}],"dnsPolicy":"ClusterFirst","restartPolicy":"Always","schedulerName":"default-scheduler","securityContext":{},"terminationGracePeriodSeconds":30,"volumes":[{"hostPath":{"path":"/proget-sql","type":"DirectoryOrCreate"},"name":"progetvol"}]}}},"status":{"availableReplicas":1,"conditions":[{"lastTransitionTime":"2019-12-06T09:20:45Z","lastUpdateTime":"2019-12-06T09:28:48Z","message":"ReplicaSet
      \"proget-b96bcb84d\" has successfully progressed.","reason":"NewReplicaSetAvailable","status":"True","type":"Progressing"},{"lastTransitionTime":"2019-12-06T09:29:10Z","lastUpdateTime":"2019-12-06T09:29:10Z","message":"Deployment
      has minimum availability.","reason":"MinimumReplicasAvailable","status":"True","type":"Available"}],"observedGeneration":5,"readyReplicas":1,"replicas":1,"updatedReplicas":1}}'
  creationTimestamp: "2019-12-08T15:05:10Z"
  generation: 23
  labels:
    cattle.io/creator: norman
    workload.user.cattle.io/workloadselector: deployment-basic-proget
  name: proget
  namespace: basic
  resourceVersion: "101210"
  selfLink: /apis/apps/v1/namespaces/basic/deployments/proget
  uid: 0010e308-3e24-4b34-945b-67723b7589ac
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      workload.user.cattle.io/workloadselector: deployment-basic-proget
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      annotations:
        cattle.io/timestamp: "2019-12-11T15:09:19Z"
        field.cattle.io/ports: '[[{"containerPort":80,"dnsName":"proget-nodeport","kind":"NodePort","name":"progetdns","protocol":"TCP"}]]'
      creationTimestamp: null
      labels:
        workload.user.cattle.io/workloadselector: deployment-basic-proget
    spec:
      containers:
      - env:
        - name: PROGET_DATABASE
          value: Data Source=localhost; Initial Catalog=ProGet; User ID=sa; Password=[password]
        - name: PROGET_DB_TYPE
          value: SqlServer
        image: inedo/proget:latest
        imagePullPolicy: Always
        name: proget
        ports:
        - containerPort: 80
          name: progetdns
          protocol: TCP
        resources: {}
        securityContext:
          allowPrivilegeEscalation: false
          privileged: false
          readOnlyRootFilesystem: false
          runAsNonRoot: false
        stdin: true
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        tty: true
        volumeMounts:
        - mountPath: /var/proget/packages
          name: progetvol
      - env:
        - name: ACCEPT_EULA
          value: "Y"
        - name: MSSQL_PID
          value: Express
        - name: MSSQL_SA_PASSWORD
          value: [password]
        image: mcr.microsoft.com/mssql/server:2017-latest
        imagePullPolicy: Always
        name: proget-sql
        resources: {}
        securityContext:
          allowPrivilegeEscalation: false
          privileged: false
          readOnlyRootFilesystem: false
          runAsNonRoot: false
        stdin: true
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        tty: true
        volumeMounts:
        - mountPath: /var/opt/mssql
          name: progetvol
      dnsConfig: {}
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
      - hostPath:
          path: /proget-sql
          type: DirectoryOrCreate
        name: progetvol
status:
  availableReplicas: 1
  conditions:
  - lastTransitionTime: "2019-12-10T15:27:50Z"
    lastUpdateTime: "2019-12-10T15:27:50Z"
    message: Deployment has minimum availability.
    reason: MinimumReplicasAvailable
    status: "True"
    type: Available
  - lastTransitionTime: "2019-12-08T15:05:10Z"
    lastUpdateTime: "2019-12-11T15:08:03Z"
    message: ReplicaSet "proget-7f9b7b9db5" has successfully progressed.
    reason: NewReplicaSetAvailable
    status: "True"
    type: Progressing
  observedGeneration: 23
  readyReplicas: 1
  replicas: 1
  updatedReplicas: 1


在数据库容器创建表

image.png

执行创建表语句 改一下[password]

/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '[password]' -Q 'CREATE DATABASE [ProGet] COLLATE SQL_Latin1_General_CP1_CI_AS'

容器仓库使用

前置条件

创建一个容器仓库

这个Repository URL可以在高级设置的 Web.BaseUrl 修改

image.png
vim /etc/docker/daemon.json

看看你的容器仓库地址,在docker的daemon.json加入以下配置

{ "insecure-registries":["192.168.101.136:30323"] }

重启下docker

systemctl daemon-reload
systemctl restart docker

登录

docker login 192.168.101.136:30323

//根据提示分别输入用户名和密码,用户密码是

上传镜像

docker push 192.168.101.136:30323/carson/nginx:v1

拉取镜像

docker pull 192.168.101.136:30323/carson/nginx:v1

镜像格式 [仓库地址]/[镜像所属用户]/[镜像名称]:[镜像版本]

注意:发布镜像时候[镜像所属用户]必须和login的用户名一致否则无法发布,实在无法一致那么就直接把镜像改名

docker tag 192.168.101.136:30323/carson/nginx:v1  192.168.101.136:30323/[你要改的名字]/nginx:v1

在k8s拉取镜像

k8s和私有仓库通讯需要创建一个secret

参数 是什么有什么作用
docker-registry 在proget设置Integrations & Extensibility里的API Keys创建
namespace k8s指定的命名空间,这个secret非全局的
docker-server 在proget的镜像仓库里的Repository URL
kubectl create secret docker-registry [key] --namespace=[k8s命名空间] \
--docker-server=http://192.168.101.136:30323/md --docker-username=[用户名] \
--docker-password=[用户密码]

然后你可以在工作负载直接部署该容器了

image.png

Nuget管理使用

发布比较简单就不说了

拉取要注意

添加自己的仓库地址 nuget.config



  
    
    
    
    
    
    
  

restore时候

dotnet restore "xxx/xxx.csproj"  --configfile "xxx/nuget.config"

你可能感兴趣的:(proget 安装与使用)