<p>I am looking to deploy a Redis instance to Kubernetes cluster.</p>
<p>In Kubernetes official website <a href="https://kubernetes.io/docs/tutorials/stateless-application/guestbook/" rel="nofollow noreferrer">here</a>, they use the following yaml configuration for example:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis-master
  labels:
    app: redis
spec:
  selector:
    matchLabels:
      app: redis
      role: master
      tier: backend
  replicas: 1
  template:
    metadata:
      labels:
        app: redis
        role: master
        tier: backend
    spec:
      containers:
      - name: master
        image: k8s.gcr.io/redis:e2e  # or just image: redis
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
        ports:
        - containerPort: 6379
</code></pre>
<p>Is 100m CPU and 100Mi of memory a good figure to aim for, when using a Redis instance for caching purposes? What should be the limit be set to?</p>

Corp. and Ltd.
<p>There is no proper answer to your question. Everything depends on your needs in this scenario.</p>
<p>You have to consider resources on your node, your <a href="https://cloud.google.com/blog/products/gcp/kubernetes-best-practices-resource-requests-and-limits" rel="nofollow noreferrer">resource requests/limits</a>, will you use <a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/" rel="nofollow noreferrer">HPA</a> or <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/verticalpodautoscaler" rel="nofollow noreferrer">VPA</a>, it's on local environment or on cloud environment, how many pods will be deployed on this node, what you will cache, etc.</p>
<h2>Background</h2>
<p>In your <code>Deployment</code> you set only <code>requests</code> so <code>redis</code> pod will alwyas have allocated at least <code>CPU: 100m</code> and <code>RAM: 100Mi</code>. As no <code>limits</code> were specified, it might use more and more resources till some errors might occur due to lack of resources (for example it can <code>terminate</code> pods without specified <code>requests</code>).
Please keep in mind that others pods which was deployed with <code>Kubernetes</code> also have some specific <code>requests</code>/<code>limits</code> like <code>kube-proxy</code> or <code>kube-dns</code>, etc.</p>
<p>To check current resource usage of your nodes you can use commands:</p>
<pre><code>$ kubectl top nodes
NAME                                       CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%
gke-cluster-1-default-pool-55c97a92-m2bb   61m          6%     718Mi           25%
gke-cluster-1-default-pool-55c97a92-s907   108m         11%    748Mi           26%
</code></pre>
<p>If you will <code>describe</code> node using <code>kubectl describe node &lt;NodeName&gt;</code> you can check node total resources in <code>Capacity</code> section and resources which are already used by kubernetes in <code>Allocatable</code>. So <code>Capacity</code> - <code>Allocatable</code> is value of your free resources in this specifc moment (it might be changed due to <code>requests</code>/<code>limits</code>).</p>
<p>As addition, you can check artice with <a href="https://sysdig.com/blog/kubernetes-limits-requests/" rel="nofollow noreferrer">Redis Request/limits</a>.</p>
<h2>Conclusion</h2>
<p><code>Redis</code> pod can be deployed with those <code>requests: 100m and 100Mi</code>. As there is no <code>limits</code> set, <code>Redis</code> pod might use more and more resources which can cause to termination of other pods. If this node will be dedicated only for <code>Redis</code> pod, you can use maximum available resources, value of <code>Capacity</code> - <code>Allocatable</code>. Now, you can set limit to half of the <code>node resources</code>, and later change it depends on results. If pod reached <code>limits</code> you can change it to higher values, if opposite, you can change to lower values.</p>
