<p>I like to create an app with kubernetes.</p>

<ul>
<li>I have api server, frontend server, a few scrapers and so on.</li>
<li>I'd like to put the api and the frontend in the same pod, and all the scrapers in other pod.</li>
<li>I'd like to be able to deploy a single project, only the api for example or a specific scraper.</li>
<li>Each app has a docker file and circle ci configuration for deploy</li>
</ul>

<p>How should I structure my project?<br>
Should each app be in it's own repository or should I use monorepo?<br>
Where should I keep the k8s.yaml (since it relates to all projects)?<br>
Where should I apply the k8s configurations? Should it happen on each deploy?
How can I config domain names for each service easily?</p>

<p>There is some points:</p>

<blockquote>
  <p>I'd like to put the api and the frontend in the same pod, and all the scrapers in other pod.</p>
</blockquote>

<p>It's ok. as long as they are on different containers in same pod. multi container pods are accessible from each other with localhost address. and pods can see each other with DNS. (and yes half healthy means unhealthy)</p>

<blockquote>
  <p>How should I structure my project?</p>
</blockquote>

<p>I use different repo for different container. but its ok for every pod = 1 repo. 
Its easier to maintain this way, and you have separate CI/CD builds which ables you to update each app separately. Storing each Deployment manifest YAML file in the root of repo is a good idea. Because one Deployment means 1 app (one set of pods).</p>

<blockquote>
  <p>Where should I apply the k8s configurations? Should it happen on each deploy? How can I config domain names for each service easily?</p>
</blockquote>

<p>In Deployment manifest file you can store configs in ENVs or use a config map. You dont need to use <code>kubectl apply</code> for each deployment.
In your CI you can do this for each deploy: </p>

<pre><code>- docker build -t {registry}:{version} .
- docker push {registry}:{version}
- kubectl set image deployment/{API_NAME} {containername}={registry}:{version} -n {NAMESPACE}
</code></pre>

<p>You need a reverse proxy in front of your APIs as a gateway, best option is Ingress which is easy to deploy and config. and it knows your pods. 
Ingress config can be like:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: api
  namespace: production
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: api.yourdomain.com
    http:
      paths:
      - path: /application1
        backend:
          serviceName: app1-production
          servicePort: 80 
      - path: /application2
        backend:
          serviceName: app2-production
          servicePort: 80 
</code></pre>

<p>or just use one subdomain per api, as you prefer. </p>
