An ink sac is an anatomical feature that is found in many cephalopod mollusks used to produce the defensive cephalopod ink. With the exception of nocturnal and very deep water cephalopods, all coeloids (squid, octopus and cuttlefish) which dwell in light conditions have an ink sac, which can be used to expel a cloud of dark ink in order to confuse predators.

Ink glands in cephalopods are used mainly for? Let's have some stream of consciousness first.
To answer the question, consider the following: An ink sac is an anatomical feature that is found in many cephalopod mollusks used to produce the defensive cephalopod ink. So, the answer is to produce the defensive cephalopod ink.