updated blocks
This commit is contained in:
parent
4cbf3d91f6
commit
aa4c393659
|
@ -38,6 +38,22 @@
|
|||
(lk/expose-cluster-ip :mosquitto-master
|
||||
(lk/port :mosquitto :mosquitto 1883 1883)))))))
|
||||
|
||||
|
||||
(defn test [kube-injector]
|
||||
(-> kube-injector
|
||||
(lk/rule :test-rule []
|
||||
(fn []
|
||||
(-> (lk/pod
|
||||
:test-pod
|
||||
{:app :test})
|
||||
(lk/add-container :busybox "busybox"
|
||||
(-> {}
|
||||
(lkh/add-to-spec :resources resources-mini)
|
||||
(lkh/add-to-spec :command ["sleep 3600"])
|
||||
(lkh/add-to-spec :envFrom [{:secretRef {:name "environment"}}])))
|
||||
(lk/deployment 1))))))
|
||||
|
||||
|
||||
(defn postgres
|
||||
([kube-injector]
|
||||
(postgres kube-injector {}))
|
||||
|
@ -84,7 +100,7 @@
|
|||
app-nginx-container-name (keyword (str app-name "-nginx-container"))
|
||||
app-nginx-pod-name (str app-name "-pod")
|
||||
app-annotations (get settings :annotations {})
|
||||
app-dependencies (get settings :dependencies [])
|
||||
app-dependencies [] ;(get settings :dependencies [])
|
||||
app-containers 1
|
||||
app-labels (get settings :labels {:app app-name})
|
||||
app-image (get settings :image "python:3")
|
||||
|
@ -93,14 +109,19 @@
|
|||
app-nginx-service-name "nginx-service"
|
||||
app-serve-static (get settings :serve-static true)]
|
||||
|
||||
|
||||
(-> kube-injector
|
||||
(lk/rule (keyword (str app-name "-rule")) app-dependencies
|
||||
(fn []
|
||||
(as-> (lk/pod
|
||||
(println app-pod-name)
|
||||
|
||||
(as->
|
||||
(lk/pod
|
||||
app-pod-name
|
||||
app-labels
|
||||
{:imagePullSecrets [{:name "docker-registry"}]})
|
||||
pod
|
||||
|
||||
; Add containers to the pod, one for frontend assets and one for backend
|
||||
(lk/add-annotation pod :linkerd.io/inject "enabled")
|
||||
(lk/add-container
|
||||
|
@ -123,7 +144,7 @@
|
|||
#_(lkh/add-readiness-probe-cmd ["wget" "127.0.0.1:5000"])
|
||||
#_(lkh/add-liveness-probe-cmd ["wget" "127.0.0.1:5000"])})
|
||||
|
||||
(lk/add-init-container
|
||||
#_(lk/add-init-container
|
||||
pod
|
||||
(keyword (str app-name "-init-migrations"))
|
||||
app-image
|
||||
|
@ -131,13 +152,13 @@
|
|||
(lkh/add-to-spec :envFrom [{:secretRef {:name "environment"}}])
|
||||
(lkh/add-to-spec :command ["./manage.py" "migrate"])))
|
||||
|
||||
(lk/add-init-container
|
||||
#_(lk/add-init-container
|
||||
pod
|
||||
(keyword (str app-name "-init-static-files"))
|
||||
app-image
|
||||
(-> {}
|
||||
(lkh/add-to-spec :envFrom [{:secretRef {:name "environment"}}])
|
||||
(lkh/add-to-spec :command ["./manage.py" "collectstatic"])))
|
||||
(lkh/add-to-spec :command ["./manage.py" "collectstatic" "--no-input"])))
|
||||
|
||||
(if (nil? app-serve-static)
|
||||
pod
|
||||
|
@ -154,15 +175,7 @@
|
|||
(lk/add-volume :static-files
|
||||
{:emptyDir {}}
|
||||
{app-nginx-container-name "/usr/share/nginx/html/static/"
|
||||
app-gunicorn-container-name "/app/staticfiles"})
|
||||
|
||||
|
||||
;{:mountPath "/usr/share/nginx/html/static/"
|
||||
; :readOnly true}
|
||||
|
||||
|
||||
#_(lk/expose-cluster-ip app-nginx-service-name
|
||||
(lk/port app-nginx-container-name :nginx-port 80 80))))
|
||||
app-gunicorn-container-name "/app/staticfiles"})))
|
||||
|
||||
|
||||
; order does matter here, deployment after initcontainers
|
||||
|
@ -170,9 +183,6 @@
|
|||
;(lku/wait-for-service-port redis :redis)
|
||||
|
||||
|
||||
#_(lk/add-volume :static-files {:configMap {:name :static-files-config-map}}
|
||||
{app-nginx-container-name "/app/staticfiles"}
|
||||
app-gunicorn-container-name "/app/staticfiles")
|
||||
; wrap in a deployment
|
||||
(lk/deployment pod 1)
|
||||
(if (nil? app-serve-static)
|
||||
|
@ -186,8 +196,7 @@
|
|||
pod
|
||||
app-service-name
|
||||
(lk/port app-gunicorn-container-name :gunicorn-port 5000 5000))
|
||||
#_(lk/expose-cluster-ip app-name
|
||||
(lk/port app-nginx-container-name :nginx-port 80 80)))))
|
||||
)))
|
||||
|
||||
; inject the ingress required to serve to gunicorn app
|
||||
(lk/rule (keyword (str app-name "-ingress-rule")) []
|
||||
|
@ -213,6 +222,40 @@
|
|||
; (lk/add-annotation :certmanager.k8s.io/cluster-issuer "letsencrypt-production")
|
||||
(lk/add-annotation :kubernetes.io/ingress.class "nginx")))))))))
|
||||
|
||||
|
||||
(defn django-huey
|
||||
([kube-injector]
|
||||
(gunicorn kube-injector {}))
|
||||
([kube-injector settings]
|
||||
(let [app-name (get settings :app-name "huey")
|
||||
app-pod-name (keyword (str app-name "-pod"))
|
||||
app-rule-name (keyword (str app-name "-rule"))
|
||||
app-container-name (keyword (str app-name "-container"))
|
||||
app-dependencies [] ;(get settings :dependencies [])
|
||||
app-containers 1
|
||||
app-labels (get settings :labels {:app app-name})
|
||||
app-image (get settings :image "python:3")
|
||||
app-resources (get settings :resources resources-small)]
|
||||
|
||||
|
||||
(-> kube-injector
|
||||
(lk/rule app-rule-name []
|
||||
(fn []
|
||||
(-> (lk/pod app-pod-name
|
||||
{:app :hackspace
|
||||
:env :stage
|
||||
:role :master
|
||||
:tier :queue}
|
||||
{:imagePullSecrets [{:name "docker-registry"}]})
|
||||
(lk/add-container
|
||||
app-container-name
|
||||
app-image
|
||||
(-> {}
|
||||
(lkh/add-to-spec :resources resources-small)
|
||||
(lkh/add-to-spec :command ["/app/manage.py" "run_huey"])
|
||||
(lkh/add-to-spec :envFrom [{:secretRef {:name "environment"}}])))
|
||||
(lk/deployment 2))))))))
|
||||
|
||||
;; (into [] (flatten ["c" [:b 2]] ))
|
||||
|
||||
|
||||
|
|
|
@ -498,6 +498,7 @@
|
|||
|
||||
(defn build [{:keys [config namespace blocks] :as service}]
|
||||
(println "Deploying" config namespace)
|
||||
(println (str namespace "-store.yaml"))
|
||||
(if (.exists (io/file (str namespace "-config.edn")))
|
||||
(do (reset! conf (clojure.edn/read-string (slurp (str namespace "-config.edn"))))
|
||||
(create-namespace-if-not-exists service)
|
||||
|
@ -505,10 +506,8 @@
|
|||
(-> injector
|
||||
(make-environment-secrets :environment (:vars @conf))
|
||||
;(make-registry-secrets :docker-registry {:.dockerconfigjson (:registry @conf)})
|
||||
;; make-ingress-hackspace
|
||||
;; database
|
||||
;; redis
|
||||
;; hackspace
|
||||
;(apply-blocks [:postgres] @conf)
|
||||
;(apply-blocks [:django-gunicorn] @conf)
|
||||
(apply-blocks blocks @conf)
|
||||
lk/standard-descs
|
||||
(lk/get-deployable deployment-config)
|
||||
|
|
Loading…
Reference in New Issue