10 U.S. Code § 12406 - National Guard in Federal service: call
Whenever—
(1) the United States, or any of the Commonwealths or possessions, is invaded or is in danger of invasion by a foreign nation;
(2) there is a rebellion or danger of a rebellion against the authority of the Government of the United States; or
(3) the President is unable with the regular forces to execute the laws of the United States; the President may call into Federal service members and units of the National Guard of any State in such numbers as he considers necessary to repel the invasion, suppress the rebellion, or execute those laws.
Orders for these purposes shall be issued through the governors of the States or, in the case of the District of Columbia, through the commanding general of the National Guard of the District of Columbia.
https://www.history.navy.mil/research/library/online-reading-room/title-list-alphabetically/p/posse-comitatus-act-and-related-matters-a-sketch.html
The Posse Comitatus Act does not apply where Congress has expressly authorized use of the military to execute the law. Congress has done so in three ways, by giving a branch of the armed forces civilian law enforcement authority, by establishing general rules for certain types of assistance, and by addressing individual cases and circumstances with more narrowly crafted legislation. Thus it has vested the Coast Guard, a branch of the armed forces, with broad law enforcement responsibilities. Second, over the years it has passed a fairly extensive array of particularized statutes, like those permitting the President to call out the armed forces in times of insurrection and domestic violence, 10 U.S.C. §§ 331-335. Finally, it has enacted general legislation authorizing the armed forces to share information and equipment with civilian law enforcement agencies, 10 U.S.C. §§ 371-382.
The legislation contains both explicit grants of authority and restrictions on the use of that authority for military assistance to the police - federal, state and local - particularly in the form of information and equipment, 10 U.S.C. §§ 371-382. Section 371 specifically authorizes the armed forces to share information acquired during military operations and in fact encourages the armed forces to plan their activities with an eye to the production of incidental civilian benefits. The section allows the use of military undercover agents and the collection of intelligence concerning civilian activities only where there is a nexus to an underlying military purpose. Under sections 372 through 374, military equipment and facilities may be made available to civilian authorities; members of the armed forces may train civilian police on the operation and maintenance of equipment and may provide them with expert advice; and military personnel may be employed to maintain and operate the equipment supplied.